mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-07-27 12:28:27 +00:00
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:
parent
89d3558804
commit
7ec3fa7139
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user