]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
lxc-checkconfig: use POSIX shell instead of bash
authorNatanael Copa <ncopa@alpinelinux.org>
Tue, 27 Nov 2012 07:27:17 +0000 (08:27 +0100)
committerStéphane Graber <stgraber@ubuntu.com>
Tue, 27 Nov 2012 15:04:49 +0000 (10:04 -0500)
- replace 'echo -e' with printf
- replace 'if [[ ... ]]' with 'if [ ... ]'
- add \ at after && and || when those are at end of line

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
src/lxc/lxc-checkconfig.in

index 7dd647622b38d86f440fad0b2d20139f4f1bfa70..d17bb95ac5ecf7b7185aa6a9688063017391859a 100644 (file)
@@ -1,13 +1,13 @@
-#!/bin/bash
+#!/bin/sh
 
 # Allow environment variables to override grep and config
 : ${CONFIG:=/proc/config.gz}
 : ${GREP:=zgrep}
 
-SETCOLOR_SUCCESS="echo -en \\033[1;32m"
-SETCOLOR_FAILURE="echo -en \\033[1;31m"
-SETCOLOR_WARNING="echo -en \\033[1;33m"
-SETCOLOR_NORMAL="echo -en \\033[0;39m"
+SETCOLOR_SUCCESS="printf \\e[1;32m"
+SETCOLOR_FAILURE="printf \\e[1;31m"
+SETCOLOR_WARNING="printf \\e[1;33m"
+SETCOLOR_NORMAL="printf \\e[0;39m"
 
 is_set() {
     $GREP -q "$1=[y|m]" $CONFIG
@@ -21,12 +21,12 @@ is_enabled() {
     RES=$?
 
     if [ $RES -eq 0 ]; then
-       $SETCOLOR_SUCCESS && echo -e "enabled" && $SETCOLOR_NORMAL
+       $SETCOLOR_SUCCESS && echo "enabled" && $SETCOLOR_NORMAL
     else
        if [ ! -z "$mandatory" -a "$mandatory" = yes ]; then
-           $SETCOLOR_FAILURE && echo -e "required" && $SETCOLOR_NORMAL
+           $SETCOLOR_FAILURE && echo "required" && $SETCOLOR_NORMAL
        else
-           $SETCOLOR_WARNING && echo -e "missing" && $SETCOLOR_NORMAL
+           $SETCOLOR_WARNING && echo "missing" && $SETCOLOR_NORMAL
        fi
     fi
 }
@@ -70,7 +70,7 @@ print_cgroups() {
 CGROUP_MNT_PATH=`print_cgroups cgroup /proc/self/mounts | head -1`
 KVER_MAJOR=$($GREP '^# Linux' $CONFIG | \
     sed -r 's/.* ([0-9])\.[0-9]{1,2}\.[0-9]{1,3}.*/\1/')
-if [[ $KVER_MAJOR == 2 ]]; then
+if [ "$KVER_MAJOR" = "2" ]; then
 KVER_MINOR=$($GREP '^# Linux' $CONFIG | \
     sed -r 's/.* 2.6.([0-9]{2}).*/\1/')
 else
@@ -82,7 +82,7 @@ echo -n "Cgroup: " && is_enabled CONFIG_CGROUPS yes
 
 if [ -f $CGROUP_MNT_PATH/cgroup.clone_children ]; then
     echo -n "Cgroup clone_children flag: " &&
-    $SETCOLOR_SUCCESS && echo -e "enabled" && $SETCOLOR_NORMAL
+    $SETCOLOR_SUCCESS && echo "enabled" && $SETCOLOR_NORMAL
 else
     echo -n "Cgroup namespace: " && is_enabled CONFIG_CGROUP_NS yes
 fi
@@ -101,12 +101,12 @@ echo "--- Misc ---"
 echo -n "Veth pair device: " && is_enabled CONFIG_VETH
 echo -n "Macvlan: " && is_enabled CONFIG_MACVLAN
 echo -n "Vlan: " && is_enabled CONFIG_VLAN_8021Q
-echo -n "File capabilities: " &&
-    ( [[ ${KVER_MAJOR} == 2 && ${KVER_MINOR} < 33 ]] &&
-       is_enabled CONFIG_SECURITY_FILE_CAPABILITIES ) ||
-    ( [[ ( ${KVER_MAJOR} == 2 && ${KVER_MINOR} > 32 ) ||
-         ${KVER_MAJOR} > 2 ]] && $SETCOLOR_SUCCESS &&
-         echo -e "enabled" && $SETCOLOR_NORMAL )
+echo -n "File capabilities: " && \
+    ( [ "${KVER_MAJOR}" = 2 ] && [ ${KVER_MINOR} -lt 33 ] && \
+       is_enabled CONFIG_SECURITY_FILE_CAPABILITIES ) || \
+    ( ( [ "${KVER_MAJOR}" = "2" ] && [ ${KVER_MINOR} -gt 32 ] ) || \
+         [ ${KVER_MAJOR} -gt 2 ] && $SETCOLOR_SUCCESS && \
+         echo "enabled" && $SETCOLOR_NORMAL )
 
 echo
 echo "Note : Before booting a new kernel, you can check its configuration"