Commit 7b3a2d33 authored by Erik Wilson's avatar Erik Wilson

Clean up check-config exit code & text

parent cc4026e1
...@@ -92,7 +92,8 @@ wrap_good() { ...@@ -92,7 +92,8 @@ wrap_good() {
echo "$(wrap_color "$1" white): $(wrap_color "$2" green)" echo "$(wrap_color "$1" white): $(wrap_color "$2" green)"
} }
wrap_bad() { wrap_bad() {
echo "$(wrap_color "$1" bold): $(wrap_color "$2" bold red)" echo "$(wrap_color "$1" bold): $(wrap_color "$2 (fail)" bold red)"
EXITCODE=$(($EXITCODE+1))
} }
wrap_warn() { wrap_warn() {
echo "$(wrap_color "$1" bold): $(wrap_color "$2" bold yellow)" echo "$(wrap_color "$1" bold): $(wrap_color "$2" bold yellow)"
...@@ -109,7 +110,6 @@ check_flag() { ...@@ -109,7 +110,6 @@ check_flag() {
else else
if [ "$IS_ERROR" = 1 ]; then if [ "$IS_ERROR" = 1 ]; then
wrap_bad "CONFIG_$1" 'missing' wrap_bad "CONFIG_$1" 'missing'
EXITCODE=1
else else
wrap_warn "CONFIG_$1" 'missing' wrap_warn "CONFIG_$1" 'missing'
fi fi
...@@ -127,7 +127,6 @@ check_command() { ...@@ -127,7 +127,6 @@ check_command() {
wrap_good "$1 command" 'available' wrap_good "$1 command" 'available'
else else
wrap_bad "$1 command" 'missing' wrap_bad "$1 command" 'missing'
EXITCODE=1
fi fi
} }
...@@ -136,7 +135,6 @@ check_device() { ...@@ -136,7 +135,6 @@ check_device() {
wrap_good "$1" 'present' wrap_good "$1" 'present'
else else
wrap_bad "$1" 'missing' wrap_bad "$1" 'missing'
EXITCODE=1
fi fi
} }
...@@ -149,7 +147,6 @@ check_distro_userns() { ...@@ -149,7 +147,6 @@ check_distro_userns() {
if ! grep -q "user_namespace.enable=1" /proc/cmdline; then if ! grep -q "user_namespace.enable=1" /proc/cmdline; then
# no user namespace support enabled # no user namespace support enabled
wrap_bad " (RHEL7/CentOS7" "User namespaces disabled; add 'user_namespace.enable=1' to boot command line)" wrap_bad " (RHEL7/CentOS7" "User namespaces disabled; add 'user_namespace.enable=1' to boot command line)"
EXITCODE=1
fi fi
fi fi
} }
...@@ -169,7 +166,6 @@ echo ...@@ -169,7 +166,6 @@ echo
else else
wrap_bad '- sha256sum' 'does not match' wrap_bad '- sha256sum' 'does not match'
cat $sumsTemp | sed 's/^/ ... /' cat $sumsTemp | sed 's/^/ ... /'
EXITCODE=1
fi fi
rm -f $sumsTemp rm -f $sumsTemp
else else
...@@ -186,8 +182,6 @@ echo ...@@ -186,8 +182,6 @@ echo
done <.links done <.links
if [ $linkFail -eq 0 ]; then if [ $linkFail -eq 0 ]; then
wrap_good '- links' 'good' wrap_good '- links' 'good'
else
EXITCODE=1
fi fi
else else
wrap_warn '- links' 'link list unavailable' wrap_warn '- links' 'link list unavailable'
...@@ -231,7 +225,6 @@ echo ...@@ -231,7 +225,6 @@ echo
iptablesMode=$(echo $iptablesInfo | awk '{ print $3 }') iptablesMode=$(echo $iptablesInfo | awk '{ print $3 }')
if [ "$iptablesMode" != "(legacy)" ]; then if [ "$iptablesMode" != "(legacy)" ]; then
wrap_bad "- $label" 'should be older than v1.8.0 or in legacy mode' wrap_bad "- $label" 'should be older than v1.8.0 or in legacy mode'
EXITCODE=1
else else
wrap_good "- $label" 'ok' wrap_good "- $label" 'ok'
fi fi
...@@ -261,7 +254,6 @@ echo ...@@ -261,7 +254,6 @@ echo
if [ "$(cat "$1")" -le "$2" ]; then if [ "$(cat "$1")" -le "$2" ]; then
wrap_bad "- $1" "$(cat "$1")" wrap_bad "- $1" "$(cat "$1")"
wrap_color " This should be set to at least $2, for example set: sysctl -w kernel/keys/root_maxkeys=1000000" bold black wrap_color " This should be set to at least $2, for example set: sysctl -w kernel/keys/root_maxkeys=1000000" bold black
EXITCODE=1
else else
wrap_good "- $1" "$(cat "$1")" wrap_good "- $1" "$(cat "$1")"
fi fi
...@@ -312,14 +304,13 @@ echo -n '- ' ...@@ -312,14 +304,13 @@ echo -n '- '
cgroupSubsystemDir="$(awk '/[, ](cpu|cpuacct|cpuset|devices|freezer|memory)[, ]/ && $3 == "cgroup" { print $2 }' /proc/mounts | head -n1)" cgroupSubsystemDir="$(awk '/[, ](cpu|cpuacct|cpuset|devices|freezer|memory)[, ]/ && $3 == "cgroup" { print $2 }' /proc/mounts | head -n1)"
cgroupDir="$(dirname "$cgroupSubsystemDir")" cgroupDir="$(dirname "$cgroupSubsystemDir")"
if [ -d "$cgroupDir/cpu" ] || [ -d "$cgroupDir/cpuacct" ] || [ -d "$cgroupDir/cpuset" ] || [ -d "$cgroupDir/devices" ] || [ -d "$cgroupDir/freezer" ] || [ -d "$cgroupDir/memory" ]; then if [ -d "$cgroupDir/cpu" ] || [ -d "$cgroupDir/cpuacct" ] || [ -d "$cgroupDir/cpuset" ] || [ -d "$cgroupDir/devices" ] || [ -d "$cgroupDir/freezer" ] || [ -d "$cgroupDir/memory" ]; then
echo "$(wrap_good 'cgroup hierarchy' 'properly mounted') [$cgroupDir]" wrap_good 'cgroup hierarchy' "properly mounted [$cgroupDir]"
else else
if [ "$cgroupSubsystemDir" ]; then if [ "$cgroupSubsystemDir" ]; then
echo "$(wrap_bad 'cgroup hierarchy' 'single mountpoint!') [$cgroupSubsystemDir]" wrap_bad 'cgroup hierarchy' "single mountpoint! [$cgroupSubsystemDir]"
else else
wrap_bad 'cgroup hierarchy' 'nonexistent??' wrap_bad 'cgroup hierarchy' 'nonexistent??'
fi fi
EXITCODE=1
echo " $(wrap_color '(see https://github.com/tianon/cgroupfs-mount)' yellow)" echo " $(wrap_color '(see https://github.com/tianon/cgroupfs-mount)' yellow)"
fi fi
...@@ -337,7 +328,6 @@ if [ "$(cat /sys/module/apparmor/parameters/enabled 2>/dev/null)" = 'Y' ]; then ...@@ -337,7 +328,6 @@ if [ "$(cat /sys/module/apparmor/parameters/enabled 2>/dev/null)" = 'Y' ]; then
else else
wrap_color '(look for an "apparmor" package for your distribution)' wrap_color '(look for an "apparmor" package for your distribution)'
fi fi
EXITCODE=1
fi fi
fi fi
...@@ -370,11 +360,9 @@ echo 'Optional Features:' ...@@ -370,11 +360,9 @@ echo 'Optional Features:'
check_flags CGROUP_PIDS check_flags CGROUP_PIDS
} }
# { # {
# CODE=${EXITCODE}
# check_flags MEMCG_SWAP MEMCG_SWAP_ENABLED # check_flags MEMCG_SWAP MEMCG_SWAP_ENABLED
# if [ -e /sys/fs/cgroup/memory/memory.memsw.limit_in_bytes ]; then # if [ -e /sys/fs/cgroup/memory/memory.memsw.limit_in_bytes ]; then
# echo " $(wrap_color '(cgroup swap accounting is currently enabled)' bold black)" # echo " $(wrap_color '(cgroup swap accounting is currently enabled)' bold black)"
# EXITCODE=${CODE}
# elif is_set MEMCG_SWAP && ! is_set MEMCG_SWAP_ENABLED; then # elif is_set MEMCG_SWAP && ! is_set MEMCG_SWAP_ENABLED; then
# echo " $(wrap_color '(cgroup swap accounting is currently not enabled, you can enable it by setting boot option "swapaccount=1")' bold black)" # echo " $(wrap_color '(cgroup swap accounting is currently not enabled, you can enable it by setting boot option "swapaccount=1")' bold black)"
# fi # fi
...@@ -457,45 +445,9 @@ check_flags CRYPTO CRYPTO_AEAD CRYPTO_GCM CRYPTO_SEQIV CRYPTO_GHASH \ ...@@ -457,45 +445,9 @@ check_flags CRYPTO CRYPTO_AEAD CRYPTO_GCM CRYPTO_SEQIV CRYPTO_GHASH \
# echo " - \"$(wrap_color 'ftp,tftp client in container' blue)\":" # echo " - \"$(wrap_color 'ftp,tftp client in container' blue)\":"
# check_flags NF_NAT_FTP NF_CONNTRACK_FTP NF_NAT_TFTP NF_CONNTRACK_TFTP | sed 's/^/ /' # check_flags NF_NAT_FTP NF_CONNTRACK_FTP NF_NAT_TFTP NF_CONNTRACK_TFTP | sed 's/^/ /'
# only fail if no storage drivers available
CODE=${EXITCODE}
EXITCODE=0
STORAGE=1
echo '- Storage Drivers:' echo '- Storage Drivers:'
# echo " - \"$(wrap_color 'aufs' blue)\":"
# check_flags AUFS_FS | sed 's/^/ /'
# if ! is_set AUFS_FS && grep -q aufs /proc/filesystems; then
# echo " $(wrap_color '(note that some kernels include AUFS patches but not the AUFS_FS flag)' bold black)"
# fi
# [ "$EXITCODE" = 0 ] && STORAGE=0
# EXITCODE=0
# echo " - \"$(wrap_color 'btrfs' blue)\":"
# check_flags BTRFS_FS | sed 's/^/ /'
# check_flags BTRFS_FS_POSIX_ACL | sed 's/^/ /'
# [ "$EXITCODE" = 0 ] && STORAGE=0
# EXITCODE=0
# echo " - \"$(wrap_color 'devicemapper' blue)\":"
# check_flags BLK_DEV_DM DM_THIN_PROVISIONING | sed 's/^/ /'
# [ "$EXITCODE" = 0 ] && STORAGE=0
# EXITCODE=0
echo " - \"$(wrap_color 'overlay' blue)\":" echo " - \"$(wrap_color 'overlay' blue)\":"
check_flags OVERLAY_FS | sed 's/^/ /' check_flags OVERLAY_FS | sed 's/^/ /'
[ "$EXITCODE" = 0 ] && STORAGE=0
EXITCODE=0
# echo " - \"$(wrap_color 'zfs' blue)\":"
# echo -n " - "; check_device /dev/zfs
# echo -n " - "; check_command zfs
# echo -n " - "; check_command zpool
# [ "$EXITCODE" = 0 ] && STORAGE=0
# EXITCODE=0
EXITCODE=$CODE
[ "$STORAGE" = 1 ] && EXITCODE=1
# --- # ---
...@@ -503,7 +455,7 @@ echo ...@@ -503,7 +455,7 @@ echo
if [ $EXITCODE -eq 0 ]; then if [ $EXITCODE -eq 0 ]; then
wrap_good 'STATUS' 'pass' wrap_good 'STATUS' 'pass'
else else
wrap_bad 'STATUS' 'fail' wrap_bad 'STATUS' $EXITCODE
fi fi
exit $EXITCODE exit $EXITCODE
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