Commit 17abf278 by Elan Ruusamäe Committed by Stéphane Graber

handle simple bashisms:

- [[ ]] -> [ ] - == -> = - source -> . - redirect of fd 200 is error in mksh, use fd 9 - &> /dev/null -> > /dev/null 2>&1 - useless function keyword - echo -e -> printf still left bash shebang which did not validate with checkbashism, mostly due 'type' being reported as bashism Signed-Off-By: 's avatarElan Ruusamäe <glen@delfi.ee> Acked-by: 's avatarStéphane Graber <stgraber@ubuntu.com>
parent 3aa0acaf
#!/bin/sh #!/bin/bash
key_sha256sums="9c102bcc376af1498d549b77bdbfa815ae86faa1d2d82f040e616b18ef2df2d4 alpine-devel@lists.alpinelinux.org-4a6a0840.rsa.pub key_sha256sums="9c102bcc376af1498d549b77bdbfa815ae86faa1d2d82f040e616b18ef2df2d4 alpine-devel@lists.alpinelinux.org-4a6a0840.rsa.pub
2adcf7ce224f476330b5360ca5edb92fd0bf91c92d83292ed028d7c4e26333ab alpine-devel@lists.alpinelinux.org-4d07755e.rsa.pub" 2adcf7ce224f476330b5360ca5edb92fd0bf91c92d83292ed028d7c4e26333ab alpine-devel@lists.alpinelinux.org-4d07755e.rsa.pub"
......
...@@ -198,7 +198,7 @@ install_altlinux() ...@@ -198,7 +198,7 @@ install_altlinux()
{ {
mkdir -p @LOCALSTATEDIR@/lock/subsys/ mkdir -p @LOCALSTATEDIR@/lock/subsys/
( (
flock -x 200 flock -x 9
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Cache repository is busy." echo "Cache repository is busy."
return 1 return 1
...@@ -228,7 +228,7 @@ install_altlinux() ...@@ -228,7 +228,7 @@ install_altlinux()
return 1 return 1
fi fi
return 0 return 0
) 200>@LOCALSTATEDIR@/lock/subsys/lxc-altlinux ) 9>@LOCALSTATEDIR@/lock/subsys/lxc-altlinux
return $? return $?
} }
...@@ -317,7 +317,7 @@ clean() ...@@ -317,7 +317,7 @@ clean()
# lock, so we won't purge while someone is creating a repository # lock, so we won't purge while someone is creating a repository
( (
flock -x 200 flock -x 9
if [ $? != 0 ]; then if [ $? != 0 ]; then
echo "Cache repository is busy." echo "Cache repository is busy."
exit 1 exit 1
...@@ -326,7 +326,7 @@ clean() ...@@ -326,7 +326,7 @@ clean()
echo -n "Purging the download cache for ALTLinux-$release..." echo -n "Purging the download cache for ALTLinux-$release..."
rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1 rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1
exit 0 exit 0
) 200>@LOCALSTATEDIR@/lock/subsys/lxc-altlinux ) 9>@LOCALSTATEDIR@/lock/subsys/lxc-altlinux
} }
usage() usage()
......
...@@ -65,7 +65,7 @@ declare -a additional_packages ...@@ -65,7 +65,7 @@ declare -a additional_packages
# ${1} - string to split # ${1} - string to split
# ${2} - separator (default is ",") # ${2} - separator (default is ",")
# ${result} - result value on success # ${result} - result value on success
function split_string { split_string() {
local ifs=${IFS} local ifs=${IFS}
IFS="${2:-,}" IFS="${2:-,}"
read -a result < <(echo "${1}") read -a result < <(echo "${1}")
...@@ -76,7 +76,7 @@ function split_string { ...@@ -76,7 +76,7 @@ function split_string {
[ -f /etc/arch-release ] && is_arch=true [ -f /etc/arch-release ] && is_arch=true
# Arch-specific preconfiguration for container # Arch-specific preconfiguration for container
function configure_arch { configure_arch() {
# read locale and timezone defaults from system rc.conf if running on Arch # read locale and timezone defaults from system rc.conf if running on Arch
if [ "${is_arch}" ]; then if [ "${is_arch}" ]; then
cp -p /etc/vconsole.conf /etc/locale.conf /etc/locale.gen "${rootfs_path}/etc/" cp -p /etc/vconsole.conf /etc/locale.conf /etc/locale.gen "${rootfs_path}/etc/"
...@@ -118,7 +118,7 @@ EOF ...@@ -118,7 +118,7 @@ EOF
} }
# write container configuration files # write container configuration files
function copy_configuration { copy_configuration() {
mkdir -p "${config_path}" mkdir -p "${config_path}"
cat > "${config_path}/config" << EOF cat > "${config_path}/config" << EOF
lxc.utsname=${name} lxc.utsname=${name}
...@@ -165,7 +165,7 @@ EOF ...@@ -165,7 +165,7 @@ EOF
} }
# install packages within container chroot # install packages within container chroot
function install_arch { install_arch() {
if ! pacstrap -dcC "${pacman_config}" "${rootfs_path}" ${base_packages[@]}; then if ! pacstrap -dcC "${pacman_config}" "${rootfs_path}" ${base_packages[@]}; then
echo "Failed to install container packages" echo "Failed to install container packages"
return 1 return 1
......
...@@ -255,8 +255,8 @@ EOF ...@@ -255,8 +255,8 @@ EOF
# add necessary config files # add necessary config files
mkdir $rootfs/etc/dropbear mkdir $rootfs/etc/dropbear
dropbearkey -t rsa -f $rootfs/etc/dropbear/dropbear_rsa_host_key &> /dev/null dropbearkey -t rsa -f $rootfs/etc/dropbear/dropbear_rsa_host_key > /dev/null 2>&1
dropbearkey -t dss -f $rootfs/etc/dropbear/dropbear_dss_host_key &> /dev/null dropbearkey -t dss -f $rootfs/etc/dropbear/dropbear_dss_host_key > /dev/null 2>&1
echo "'dropbear' ssh utility installed" echo "'dropbear' ssh utility installed"
fi fi
......
...@@ -133,7 +133,7 @@ configure_centos() ...@@ -133,7 +133,7 @@ configure_centos()
echo 0 > $rootfs_path/selinux/enforce echo 0 > $rootfs_path/selinux/enforce
# Also kill it in the /etc/selinux/config file if it's there... # Also kill it in the /etc/selinux/config file if it's there...
if [[ -f $rootfs_path/etc/selinux/config ]] if [ -f $rootfs_path/etc/selinux/config ]
then then
sed -i '/^SELINUX=/s/.*/SELINUX=disabled/' $rootfs_path/etc/selinux/config sed -i '/^SELINUX=/s/.*/SELINUX=disabled/' $rootfs_path/etc/selinux/config
fi fi
...@@ -419,7 +419,7 @@ install_centos() ...@@ -419,7 +419,7 @@ install_centos()
{ {
mkdir -p /var/lock/subsys/ mkdir -p /var/lock/subsys/
( (
flock -x 200 flock -x 9
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Cache repository is busy." echo "Cache repository is busy."
return 1 return 1
...@@ -451,7 +451,7 @@ install_centos() ...@@ -451,7 +451,7 @@ install_centos()
return 0 return 0
) 200>/var/lock/subsys/lxc-centos ) 9>/var/lock/subsys/lxc-centos
return $? return $?
} }
...@@ -522,7 +522,7 @@ clean() ...@@ -522,7 +522,7 @@ clean()
# lock, so we won't purge while someone is creating a repository # lock, so we won't purge while someone is creating a repository
( (
flock -x 200 flock -x 9
if [ $? != 0 ]; then if [ $? != 0 ]; then
echo "Cache repository is busy." echo "Cache repository is busy."
exit 1 exit 1
...@@ -532,7 +532,7 @@ clean() ...@@ -532,7 +532,7 @@ clean()
rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1 rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1
exit 0 exit 0
) 200>/var/lock/subsys/lxc-centos ) 9>/var/lock/subsys/lxc-centos
} }
usage() usage()
......
...@@ -98,7 +98,7 @@ EOF ...@@ -98,7 +98,7 @@ EOF
cat /etc/timezone > $rootfs/etc/timezone cat /etc/timezone > $rootfs/etc/timezone
chroot $rootfs dpkg-reconfigure -f noninteractive tzdata chroot $rootfs dpkg-reconfigure -f noninteractive tzdata
elif [ -f /etc/sysconfig/clock ]; then elif [ -f /etc/sysconfig/clock ]; then
source /etc/sysconfig/clock . /etc/sysconfig/clock
echo $ZONE > $rootfs/etc/timezone echo $ZONE > $rootfs/etc/timezone
chroot $rootfs dpkg-reconfigure -f noninteractive tzdata chroot $rootfs dpkg-reconfigure -f noninteractive tzdata
else else
...@@ -184,7 +184,7 @@ install_debian() ...@@ -184,7 +184,7 @@ install_debian()
arch=$3 arch=$3
mkdir -p @LOCALSTATEDIR@/lock/subsys/ mkdir -p @LOCALSTATEDIR@/lock/subsys/
( (
flock -x 200 flock -x 9
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Cache repository is busy." echo "Cache repository is busy."
return 1 return 1
...@@ -207,7 +207,7 @@ install_debian() ...@@ -207,7 +207,7 @@ install_debian()
return 0 return 0
) 200>@LOCALSTATEDIR@/lock/subsys/lxc-debian ) 9>@LOCALSTATEDIR@/lock/subsys/lxc-debian
return $? return $?
} }
...@@ -277,7 +277,7 @@ clean() ...@@ -277,7 +277,7 @@ clean()
# lock, so we won't purge while someone is creating a repository # lock, so we won't purge while someone is creating a repository
( (
flock -x 200 flock -x 9
if [ $? != 0 ]; then if [ $? != 0 ]; then
echo "Cache repository is busy." echo "Cache repository is busy."
exit 1 exit 1
...@@ -287,7 +287,7 @@ clean() ...@@ -287,7 +287,7 @@ clean()
rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1 rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1
exit 0 exit 0
) 200>@LOCALSTATEDIR@/lock/subsys/lxc-debian ) 9>@LOCALSTATEDIR@/lock/subsys/lxc-debian
} }
usage() usage()
...@@ -341,11 +341,11 @@ if [ ! -z "$clean" -a -z "$path" ]; then ...@@ -341,11 +341,11 @@ if [ ! -z "$clean" -a -z "$path" ]; then
exit 0 exit 0
fi fi
if [ "$arch" == "i686" ]; then if [ "$arch" = "i686" ]; then
arch=i386 arch=i386
fi fi
if [ "$arch" == "x86_64" ]; then if [ "$arch" = "x86_64" ]; then
arch=amd64 arch=amd64
fi fi
......
...@@ -96,7 +96,7 @@ populate_dev() ...@@ -96,7 +96,7 @@ populate_dev()
set_guest_root_password() set_guest_root_password()
{ {
[[ -z "$root_password" ]] && return # pass is empty, abort [ -z "$root_password" ] && return # pass is empty, abort
echo " - setting guest root password.." echo " - setting guest root password.."
echo "root passwd is: $root_password" echo "root passwd is: $root_password"
...@@ -173,7 +173,7 @@ install_openmandriva() ...@@ -173,7 +173,7 @@ install_openmandriva()
{ {
mkdir -p @LOCALSTATEDIR@/lock/subsys/ mkdir -p @LOCALSTATEDIR@/lock/subsys/
( (
flock -x 200 flock -x 9
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Cache repository is busy." echo "Cache repository is busy."
return 1 return 1
...@@ -204,7 +204,7 @@ install_openmandriva() ...@@ -204,7 +204,7 @@ install_openmandriva()
return 1 return 1
fi fi
return 0 return 0
) 200>@LOCALSTATEDIR@/lock/subsys/lxc-openmandriva ) 9>@LOCALSTATEDIR@/lock/subsys/lxc-openmandriva
return $? return $?
} }
...@@ -294,7 +294,7 @@ clean() ...@@ -294,7 +294,7 @@ clean()
# lock, so we won't purge while someone is creating a repository # lock, so we won't purge while someone is creating a repository
( (
flock -x 200 flock -x 9
if [ $? != 0 ]; then if [ $? != 0 ]; then
echo "Cache repository is busy." echo "Cache repository is busy."
exit 1 exit 1
...@@ -303,7 +303,7 @@ clean() ...@@ -303,7 +303,7 @@ clean()
echo -n "Purging the download cache for OpenMandriva-$release..." echo -n "Purging the download cache for OpenMandriva-$release..."
rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1 rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1
exit 0 exit 0
) 200>@LOCALSTATEDIR@/lock/subsys/lxc-openmandriva ) 9>@LOCALSTATEDIR@/lock/subsys/lxc-openmandriva
} }
usage() usage()
......
...@@ -150,7 +150,7 @@ Support: pwdutils rpcbind sysconfig ...@@ -150,7 +150,7 @@ Support: pwdutils rpcbind sysconfig
Ignore: rpm:suse-build-key,build-key Ignore: rpm:suse-build-key,build-key
Ignore: systemd:systemd-presets-branding Ignore: systemd:systemd-presets-branding
EOF EOF
if [ "$arch" == "i686" ]; then if [ "$arch" = "i686" ]; then
mkdir -p $cache/partial-$arch-packages/var/cache/zypp/packages/repo-oss/suse/i686/ mkdir -p $cache/partial-$arch-packages/var/cache/zypp/packages/repo-oss/suse/i686/
for i in "$cache/partial-$arch-packages/var/cache/zypp/packages/repo-oss/suse/i586/*" ; do for i in "$cache/partial-$arch-packages/var/cache/zypp/packages/repo-oss/suse/i586/*" ; do
ln -s $i $cache/partial-$arch-packages/var/cache/zypp/packages/repo-oss/suse/i686/ ln -s $i $cache/partial-$arch-packages/var/cache/zypp/packages/repo-oss/suse/i686/
...@@ -209,7 +209,7 @@ install_opensuse() ...@@ -209,7 +209,7 @@ install_opensuse()
rootfs=$1 rootfs=$1
mkdir -p @LOCALSTATEDIR@/lock/subsys/ mkdir -p @LOCALSTATEDIR@/lock/subsys/
( (
flock -x 200 flock -x 9
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Cache repository is busy." echo "Cache repository is busy."
return 1 return 1
...@@ -234,7 +234,7 @@ install_opensuse() ...@@ -234,7 +234,7 @@ install_opensuse()
fi fi
return 0 return 0
) 200>@LOCALSTATEDIR@/lock/subsys/lxc-opensuse ) 9>@LOCALSTATEDIR@/lock/subsys/lxc-opensuse
return $? return $?
} }
...@@ -325,7 +325,7 @@ clean() ...@@ -325,7 +325,7 @@ clean()
# lock, so we won't purge while someone is creating a repository # lock, so we won't purge while someone is creating a repository
( (
flock -x 200 flock -x 9
if [ $? != 0 ]; then if [ $? != 0 ]; then
echo "Cache repository is busy." echo "Cache repository is busy."
exit 1 exit 1
...@@ -334,7 +334,7 @@ clean() ...@@ -334,7 +334,7 @@ clean()
echo -n "Purging the download cache..." echo -n "Purging the download cache..."
rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1 rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1
exit 0 exit 0
) 200>@LOCALSTATEDIR@/lock/subsys/lxc-opensuse ) 9>@LOCALSTATEDIR@/lock/subsys/lxc-opensuse
} }
usage() usage()
......
#!/bin/bash #!/bin/sh
# #
# Template script for generating Oracle Enterprise Linux container for LXC # Template script for generating Oracle Enterprise Linux container for LXC
# based on lxc-fedora, lxc-ubuntu # based on lxc-fedora, lxc-ubuntu
...@@ -362,8 +362,8 @@ EOF ...@@ -362,8 +362,8 @@ EOF
chroot $container_rootfs useradd -m -s /bin/bash oracle chroot $container_rootfs useradd -m -s /bin/bash oracle
echo "oracle:oracle" | chroot $container_rootfs chpasswd echo "oracle:oracle" | chroot $container_rootfs chpasswd
echo "root:root" | chroot $container_rootfs chpasswd echo "root:root" | chroot $container_rootfs chpasswd
echo -e "Added container user:\033[1moracle\033[0m password:\033[1moracle\033[0m" printf "Added container user:\033[1moracle\033[0m password:\033[1moracle\033[0m\n"
echo -e "Added container user:\033[1mroot\033[0m password:\033[1mroot\033[0m" printf "Added container user:\033[1mroot\033[0m password:\033[1mroot\033[0m\n"
} }
# create the container's lxc config file # create the container's lxc config file
...@@ -478,7 +478,7 @@ container_rootfs_create() ...@@ -478,7 +478,7 @@ container_rootfs_create()
mkdir -p @LOCALSTATEDIR@/lock/subsys/lxc mkdir -p @LOCALSTATEDIR@/lock/subsys/lxc
( (
flock -x 200 flock -x 9
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
die "The template is busy." die "The template is busy."
fi fi
...@@ -612,7 +612,7 @@ container_rootfs_create() ...@@ -612,7 +612,7 @@ container_rootfs_create()
rm -f $container_rootfs/var/lib/rpm/__db* rm -f $container_rootfs/var/lib/rpm/__db*
chroot $container_rootfs rpm --rebuilddb >/dev/null 2>&1 chroot $container_rootfs rpm --rebuilddb >/dev/null 2>&1
) 200>@LOCALSTATEDIR@/lock/subsys/lxc-oracle-$name ) 9>@LOCALSTATEDIR@/lock/subsys/lxc-oracle-$name
} }
container_release_get() container_release_get()
......
...@@ -202,7 +202,7 @@ if [ "$(id -u)" != "0" ]; then ...@@ -202,7 +202,7 @@ if [ "$(id -u)" != "0" ]; then
exit 1 exit 1
fi fi
if [ $0 == "/sbin/init" ]; then if [ $0 = "/sbin/init" ]; then
PATH="$PATH:/bin:/sbin:/usr/sbin" PATH="$PATH:/bin:/sbin:/usr/sbin"
check_for_cmd @LXCINITDIR@/lxc/lxc-init check_for_cmd @LXCINITDIR@/lxc/lxc-init
......
...@@ -105,7 +105,7 @@ EOF ...@@ -105,7 +105,7 @@ EOF
cat /etc/timezone > $rootfs/etc/timezone cat /etc/timezone > $rootfs/etc/timezone
chroot $rootfs dpkg-reconfigure -f noninteractive tzdata chroot $rootfs dpkg-reconfigure -f noninteractive tzdata
elif [ -f /etc/sysconfig/clock ]; then elif [ -f /etc/sysconfig/clock ]; then
source /etc/sysconfig/clock . /etc/sysconfig/clock
echo $ZONE > $rootfs/etc/timezone echo $ZONE > $rootfs/etc/timezone
chroot $rootfs dpkg-reconfigure -f noninteractive tzdata chroot $rootfs dpkg-reconfigure -f noninteractive tzdata
else else
...@@ -222,7 +222,7 @@ if [ $debug -eq 1 ]; then ...@@ -222,7 +222,7 @@ if [ $debug -eq 1 ]; then
set -x set -x
fi fi
if [ "$arch" == "i686" ]; then if [ "$arch" = "i686" ]; then
arch=i386 arch=i386
fi fi
...@@ -373,9 +373,9 @@ if [ -n "$tarball" ]; then ...@@ -373,9 +373,9 @@ if [ -n "$tarball" ]; then
else else
mkdir -p "$STATE_DIR/lock/subsys/" mkdir -p "$STATE_DIR/lock/subsys/"
( (
flock -x 200 flock -x 9
do_extract_rootfs do_extract_rootfs
) 200>"$STATE_DIR/lock/subsys/lxc-ubuntu-cloud" ) 9>"$STATE_DIR/lock/subsys/lxc-ubuntu-cloud"
fi fi
copy_configuration $path $rootfs $name $arch $release copy_configuration $path $rootfs $name $arch $release
......
...@@ -338,7 +338,7 @@ install_ubuntu() ...@@ -338,7 +338,7 @@ install_ubuntu()
mkdir -p $LOCALSTATEDIR/lock/subsys/ mkdir -p $LOCALSTATEDIR/lock/subsys/
( (
flock -x 200 flock -x 9
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Cache repository is busy." echo "Cache repository is busy."
return 1 return 1
...@@ -369,7 +369,7 @@ install_ubuntu() ...@@ -369,7 +369,7 @@ install_ubuntu()
return 0 return 0
) 200>$LOCALSTATEDIR/lock/subsys/lxc-ubuntu$release ) 9>$LOCALSTATEDIR/lock/subsys/lxc-ubuntu$release
return $? return $?
} }
...@@ -519,7 +519,7 @@ EOF ...@@ -519,7 +519,7 @@ EOF
cat /etc/timezone > $rootfs/etc/timezone cat /etc/timezone > $rootfs/etc/timezone
chroot $rootfs dpkg-reconfigure -f noninteractive tzdata chroot $rootfs dpkg-reconfigure -f noninteractive tzdata
elif [ -f /etc/sysconfig/clock ]; then elif [ -f /etc/sysconfig/clock ]; then
source /etc/sysconfig/clock . /etc/sysconfig/clock
echo $ZONE > $rootfs/etc/timezone echo $ZONE > $rootfs/etc/timezone
chroot $rootfs dpkg-reconfigure -f noninteractive tzdata chroot $rootfs dpkg-reconfigure -f noninteractive tzdata
else else
...@@ -670,7 +670,7 @@ if [ -n "$bindhome" ]; then ...@@ -670,7 +670,7 @@ if [ -n "$bindhome" ]; then
fi fi
if [ "$arch" == "i686" ]; then if [ "$arch" = "i686" ]; then
arch=i386 arch=i386
fi fi
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment