]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
handle simple bashisms:
authorElan Ruusamäe <glen@delfi.ee>
Mon, 13 Jan 2014 08:26:09 +0000 (10:26 +0200)
committerStéphane Graber <stgraber@ubuntu.com>
Tue, 14 Jan 2014 21:16:00 +0000 (16:16 -0500)
- [[ ]] -> [ ]
- == -> =
- 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: Elan Ruusamäe <glen@delfi.ee>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
12 files changed:
templates/lxc-alpine.in
templates/lxc-altlinux.in
templates/lxc-archlinux.in
templates/lxc-busybox.in
templates/lxc-centos.in
templates/lxc-debian.in
templates/lxc-openmandriva.in
templates/lxc-opensuse.in
templates/lxc-oracle.in
templates/lxc-sshd.in
templates/lxc-ubuntu-cloud.in
templates/lxc-ubuntu.in

index 56236a4cc32b82cb2874707ac15eb58df6a72084..ac328a4d48680725709eb294dec6d3ca5b269c5d 100644 (file)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 
 key_sha256sums="9c102bcc376af1498d549b77bdbfa815ae86faa1d2d82f040e616b18ef2df2d4  alpine-devel@lists.alpinelinux.org-4a6a0840.rsa.pub
 2adcf7ce224f476330b5360ca5edb92fd0bf91c92d83292ed028d7c4e26333ab  alpine-devel@lists.alpinelinux.org-4d07755e.rsa.pub"
index 99d31e8e46338cda79ecf60cf882524cac706619..1a586d8ad44bb553edd05d4192fe6a76a17a6aa0 100644 (file)
@@ -198,7 +198,7 @@ install_altlinux()
 {
     mkdir -p @LOCALSTATEDIR@/lock/subsys/
     (
-        flock -x 200
+        flock -x 9
         if [ $? -ne 0 ]; then
             echo "Cache repository is busy."
             return 1
@@ -228,7 +228,7 @@ install_altlinux()
             return 1
         fi
         return 0
-    ) 200>@LOCALSTATEDIR@/lock/subsys/lxc-altlinux
+    ) 9>@LOCALSTATEDIR@/lock/subsys/lxc-altlinux
 
     return $?
 }
@@ -317,7 +317,7 @@ clean()
 
     # lock, so we won't purge while someone is creating a repository
     (
-        flock -x 200
+        flock -x 9
         if [ $? != 0 ]; then
             echo "Cache repository is busy."
             exit 1
@@ -326,7 +326,7 @@ clean()
         echo -n "Purging the download cache for ALTLinux-$release..."
         rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1
         exit 0
-    ) 200>@LOCALSTATEDIR@/lock/subsys/lxc-altlinux
+    ) 9>@LOCALSTATEDIR@/lock/subsys/lxc-altlinux
 }
 
 usage()
index e3c01d51a4df2ab4d4335af5aba4529003a204b2..5e3493bd52da81f060f7ad13a88b2a94bd56f3a6 100644 (file)
@@ -65,7 +65,7 @@ declare -a additional_packages
 # ${1} - string to split
 # ${2} - separator (default is ",")
 # ${result} - result value on success
-function split_string {
+split_string() {
     local ifs=${IFS}
     IFS="${2:-,}"
     read -a result < <(echo "${1}")
@@ -76,7 +76,7 @@ function split_string {
 [ -f /etc/arch-release ] && is_arch=true
 
 # Arch-specific preconfiguration for container
-function configure_arch {
+configure_arch() {
     # read locale and timezone defaults from system rc.conf if running on Arch
     if [ "${is_arch}" ]; then
         cp -p /etc/vconsole.conf /etc/locale.conf /etc/locale.gen "${rootfs_path}/etc/"
@@ -118,7 +118,7 @@ EOF
 }
 
 # write container configuration files
-function copy_configuration {
+copy_configuration() {
     mkdir -p "${config_path}"
     cat > "${config_path}/config" << EOF
 lxc.utsname=${name}
@@ -165,7 +165,7 @@ EOF
 }
 
 # install packages within container chroot
-function install_arch {
+install_arch() {
     if ! pacstrap -dcC "${pacman_config}" "${rootfs_path}" ${base_packages[@]}; then
         echo "Failed to install container packages"
         return 1
index 974377d0765b17491d34a6aeb76f5511bbf417da..3568c0cfa5e2f95526edb1b3e1c5c92e9834ee9e 100644 (file)
@@ -255,8 +255,8 @@ EOF
 
         # add necessary config files
         mkdir $rootfs/etc/dropbear
-        dropbearkey -t rsa -f $rootfs/etc/dropbear/dropbear_rsa_host_key &> /dev/null
-        dropbearkey -t dss -f $rootfs/etc/dropbear/dropbear_dss_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 2>&1
 
         echo "'dropbear' ssh utility installed"
     fi
index 3126bba1b7a5d0bf555d736428a51dc99c3a3233..ba6ee840f6ab29bcb39885b51ac7503df93c6244 100644 (file)
@@ -133,7 +133,7 @@ configure_centos()
     echo 0 > $rootfs_path/selinux/enforce
 
     # 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
         sed -i '/^SELINUX=/s/.*/SELINUX=disabled/' $rootfs_path/etc/selinux/config
     fi
@@ -419,7 +419,7 @@ install_centos()
 {
     mkdir -p /var/lock/subsys/
     (
-    flock -x 200
+    flock -x 9
     if [ $? -ne 0 ]; then
         echo "Cache repository is busy."
         return 1
@@ -451,7 +451,7 @@ install_centos()
 
     return 0
 
-    ) 200>/var/lock/subsys/lxc-centos
+    ) 9>/var/lock/subsys/lxc-centos
 
     return $?
 }
@@ -522,7 +522,7 @@ clean()
 
     # lock, so we won't purge while someone is creating a repository
     (
-    flock -x 200
+    flock -x 9
     if [ $? != 0 ]; then
         echo "Cache repository is busy."
         exit 1
@@ -532,7 +532,7 @@ clean()
     rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1
     exit 0
 
-    ) 200>/var/lock/subsys/lxc-centos
+    ) 9>/var/lock/subsys/lxc-centos
 }
 
 usage()
index 4612b730a9ea21d85d13e635c2bf6ed25a692c62..d6f07b9980099a521154392a9ba947578b895bb9 100644 (file)
@@ -98,7 +98,7 @@ EOF
         cat /etc/timezone > $rootfs/etc/timezone
         chroot $rootfs dpkg-reconfigure -f noninteractive tzdata
     elif [ -f /etc/sysconfig/clock ]; then
-        source /etc/sysconfig/clock
+        . /etc/sysconfig/clock
         echo $ZONE > $rootfs/etc/timezone
         chroot $rootfs dpkg-reconfigure -f noninteractive tzdata
     else
@@ -184,7 +184,7 @@ install_debian()
     arch=$3
     mkdir -p @LOCALSTATEDIR@/lock/subsys/
     (
-        flock -x 200
+        flock -x 9
         if [ $? -ne 0 ]; then
             echo "Cache repository is busy."
             return 1
@@ -207,7 +207,7 @@ install_debian()
 
         return 0
 
-        ) 200>@LOCALSTATEDIR@/lock/subsys/lxc-debian
+        ) 9>@LOCALSTATEDIR@/lock/subsys/lxc-debian
 
     return $?
 }
@@ -277,7 +277,7 @@ clean()
 
     # lock, so we won't purge while someone is creating a repository
     (
-        flock -x 200
+        flock -x 9
         if [ $? != 0 ]; then
             echo "Cache repository is busy."
             exit 1
@@ -287,7 +287,7 @@ clean()
         rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1
         exit 0
 
-    ) 200>@LOCALSTATEDIR@/lock/subsys/lxc-debian
+    ) 9>@LOCALSTATEDIR@/lock/subsys/lxc-debian
 }
 
 usage()
@@ -341,11 +341,11 @@ if [ ! -z "$clean" -a -z "$path" ]; then
     exit 0
 fi
 
-if [ "$arch" == "i686" ]; then
+if [ "$arch" = "i686" ]; then
     arch=i386
 fi
 
-if [ "$arch" == "x86_64" ]; then
+if [ "$arch" = "x86_64" ]; then
     arch=amd64
 fi
 
index 75d310a99c1f20e8e2c121c0781d3771d8850c89..eddaad0356d6291637f4f5eb1f49805a3db38f96 100644 (file)
@@ -96,7 +96,7 @@ populate_dev()
 
 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 "root passwd is: $root_password"
@@ -173,7 +173,7 @@ install_openmandriva()
 {
     mkdir -p @LOCALSTATEDIR@/lock/subsys/
     (
-        flock -x 200
+        flock -x 9
         if [ $? -ne 0 ]; then
             echo "Cache repository is busy."
             return 1
@@ -204,7 +204,7 @@ install_openmandriva()
             return 1
         fi
         return 0
-    ) 200>@LOCALSTATEDIR@/lock/subsys/lxc-openmandriva
+    ) 9>@LOCALSTATEDIR@/lock/subsys/lxc-openmandriva
 
     return $?
 }
@@ -294,7 +294,7 @@ clean()
 
     # lock, so we won't purge while someone is creating a repository
     (
-        flock -x 200
+        flock -x 9
         if [ $? != 0 ]; then
             echo "Cache repository is busy."
             exit 1
@@ -303,7 +303,7 @@ clean()
         echo -n "Purging the download cache for OpenMandriva-$release..."
         rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1
         exit 0
-    ) 200>@LOCALSTATEDIR@/lock/subsys/lxc-openmandriva
+    ) 9>@LOCALSTATEDIR@/lock/subsys/lxc-openmandriva
 }
 
 usage()
index 220176fd95b3543e19daa8ab352692f292d8bd0d..89ae8bd9b7a6ac648a96498619636f13f7476107 100644 (file)
@@ -150,7 +150,7 @@ Support: pwdutils rpcbind sysconfig
 Ignore: rpm:suse-build-key,build-key
 Ignore: systemd:systemd-presets-branding
 EOF
-    if [ "$arch" == "i686" ]; then
+    if [ "$arch" = "i686" ]; then
         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
             ln -s $i $cache/partial-$arch-packages/var/cache/zypp/packages/repo-oss/suse/i686/
@@ -209,7 +209,7 @@ install_opensuse()
     rootfs=$1
     mkdir -p @LOCALSTATEDIR@/lock/subsys/
     (
-        flock -x 200
+        flock -x 9
         if [ $? -ne 0 ]; then
             echo "Cache repository is busy."
             return 1
@@ -234,7 +234,7 @@ install_opensuse()
         fi
 
         return 0
-    ) 200>@LOCALSTATEDIR@/lock/subsys/lxc-opensuse
+    ) 9>@LOCALSTATEDIR@/lock/subsys/lxc-opensuse
 
     return $?
 }
@@ -325,7 +325,7 @@ clean()
 
     # lock, so we won't purge while someone is creating a repository
     (
-        flock -x 200
+        flock -x 9
         if [ $? != 0 ]; then
             echo "Cache repository is busy."
             exit 1
@@ -334,7 +334,7 @@ clean()
         echo -n "Purging the download cache..."
         rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1
         exit 0
-    ) 200>@LOCALSTATEDIR@/lock/subsys/lxc-opensuse
+    ) 9>@LOCALSTATEDIR@/lock/subsys/lxc-opensuse
 }
 
 usage()
index 3461e739d740d00365a6899ff8390cc8afd2d25f..6ae60b044b7c9256576d59f2a521f27afa65d962 100644 (file)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 #
 # Template script for generating Oracle Enterprise Linux container for LXC
 # based on lxc-fedora, lxc-ubuntu
@@ -362,8 +362,8 @@ EOF
     chroot $container_rootfs useradd -m -s /bin/bash oracle
     echo "oracle:oracle" | 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"
-    echo -e "Added container user:\033[1mroot\033[0m password:\033[1mroot\033[0m"
+    printf "Added container user:\033[1moracle\033[0m password:\033[1moracle\033[0m\n"
+    printf "Added container user:\033[1mroot\033[0m password:\033[1mroot\033[0m\n"
 }
 
 # create the container's lxc config file
@@ -478,7 +478,7 @@ container_rootfs_create()
 
     mkdir -p @LOCALSTATEDIR@/lock/subsys/lxc
     (
-        flock -x 200
+        flock -x 9
         if [ $? -ne 0 ]; then
             die "The template is busy."
         fi
@@ -612,7 +612,7 @@ container_rootfs_create()
         rm -f $container_rootfs/var/lib/rpm/__db*
         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()
index bbbea62f97063b917c87b39c67e5665b5f5d8c63..74467bbdbb5dc1122efc3084417958b6f87c98aa 100644 (file)
@@ -202,7 +202,7 @@ if [ "$(id -u)" != "0" ]; then
     exit 1
 fi
 
-if [ $0 == "/sbin/init" ]; then
+if [ $0 = "/sbin/init" ]; then
 
     PATH="$PATH:/bin:/sbin:/usr/sbin"
     check_for_cmd @LXCINITDIR@/lxc/lxc-init
index 42b0506a4316eaaedd5215b74c5bae4772d7c949..2cf86c953934981e6b431cbe01f182ce33e964b5 100644 (file)
@@ -105,7 +105,7 @@ EOF
         cat /etc/timezone > $rootfs/etc/timezone
         chroot $rootfs dpkg-reconfigure -f noninteractive tzdata
     elif [ -f /etc/sysconfig/clock ]; then
-        source /etc/sysconfig/clock
+        . /etc/sysconfig/clock
         echo $ZONE > $rootfs/etc/timezone
         chroot $rootfs dpkg-reconfigure -f noninteractive tzdata
     else
@@ -222,7 +222,7 @@ if [ $debug -eq 1 ]; then
     set -x
 fi
 
-if [ "$arch" == "i686" ]; then
+if [ "$arch" = "i686" ]; then
     arch=i386
 fi
 
@@ -373,9 +373,9 @@ if [ -n "$tarball" ]; then
 else
     mkdir -p "$STATE_DIR/lock/subsys/"
     (
-        flock -x 200
+        flock -x 9
         do_extract_rootfs
-    ) 200>"$STATE_DIR/lock/subsys/lxc-ubuntu-cloud"
+    ) 9>"$STATE_DIR/lock/subsys/lxc-ubuntu-cloud"
 fi
 
 copy_configuration $path $rootfs $name $arch $release
index 586ba072b0be39d3fdfa4fe4fb89d37163602080..dfe874d0bb16cafeafbc38cb709f37adf10e5680 100644 (file)
@@ -338,7 +338,7 @@ install_ubuntu()
     mkdir -p $LOCALSTATEDIR/lock/subsys/
 
     (
-        flock -x 200
+        flock -x 9
         if [ $? -ne 0 ]; then
             echo "Cache repository is busy."
             return 1
@@ -369,7 +369,7 @@ install_ubuntu()
 
         return 0
 
-    ) 200>$LOCALSTATEDIR/lock/subsys/lxc-ubuntu$release
+    ) 9>$LOCALSTATEDIR/lock/subsys/lxc-ubuntu$release
 
     return $?
 }
@@ -519,7 +519,7 @@ EOF
         cat /etc/timezone > $rootfs/etc/timezone
         chroot $rootfs dpkg-reconfigure -f noninteractive tzdata
     elif [ -f /etc/sysconfig/clock ]; then
-        source /etc/sysconfig/clock
+        . /etc/sysconfig/clock
         echo $ZONE > $rootfs/etc/timezone
         chroot $rootfs dpkg-reconfigure -f noninteractive tzdata
     else
@@ -670,7 +670,7 @@ if [ -n "$bindhome" ]; then
 fi
 
 
-if [ "$arch" == "i686" ]; then
+if [ "$arch" = "i686" ]; then
     arch=i386
 fi