lxc-checkconfig: use POSIX shell instead of bash

- 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>
This commit is contained in:
Natanael Copa 2012-11-27 08:27:17 +01:00 committed by Stéphane Graber
parent 89d3558804
commit 7ec3fa7139

View File

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