mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
script/check-config.sh: fix wrap_color usage
1. Allow wrap_bad and wrap_good to have an optional arguments.
2. Remove unneeded echos; this fixes the shellcheck warnings like
In ./script/check-config.sh line 178:
echo "$(wrap_bad 'cgroup hierarchy' 'nonexistent??')"
^-- SC2005 (style): Useless echo? Instead of 'echo $(cmd)', just use 'cmd'.
3. Fix missing color argument in calls to wrap_color (when printing the
hint about how to install apparmor).
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
+22
-13
@@ -73,10 +73,19 @@ wrap_color() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
wrap_good() {
|
wrap_good() {
|
||||||
echo "$(wrap_color "$1" white): $(wrap_color "$2" green)"
|
local name="$1"
|
||||||
|
shift
|
||||||
|
local val="$1"
|
||||||
|
shift
|
||||||
|
echo "$(wrap_color "$name" white): $(wrap_color "$val" green)" "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
wrap_bad() {
|
wrap_bad() {
|
||||||
echo "$(wrap_color "$1" bold): $(wrap_color "$2" bold red)"
|
local name="$1"
|
||||||
|
shift
|
||||||
|
local val="$1"
|
||||||
|
shift
|
||||||
|
echo "$(wrap_color "$name" bold): $(wrap_color "$val" bold red)" "$@"
|
||||||
}
|
}
|
||||||
wrap_warning() {
|
wrap_warning() {
|
||||||
wrap_color >&2 "$*" red
|
wrap_color >&2 "$*" red
|
||||||
@@ -165,35 +174,35 @@ echo 'Generally Necessary:'
|
|||||||
|
|
||||||
echo -n '- '
|
echo -n '- '
|
||||||
if [ "$(stat -f -c %t /sys/fs/cgroup 2>/dev/null)" = "63677270" ]; then
|
if [ "$(stat -f -c %t /sys/fs/cgroup 2>/dev/null)" = "63677270" ]; then
|
||||||
echo "$(wrap_good 'cgroup hierarchy' 'cgroupv2')"
|
wrap_good 'cgroup hierarchy' 'cgroupv2'
|
||||||
else
|
else
|
||||||
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" -o -d "$cgroupDir/cpuacct" -o -d "$cgroupDir/cpuset" -o -d "$cgroupDir/devices" -o -d "$cgroupDir/freezer" -o -d "$cgroupDir/memory" ]; then
|
if [ -d "$cgroupDir/cpu" -o -d "$cgroupDir/cpuacct" -o -d "$cgroupDir/cpuset" -o -d "$cgroupDir/devices" -o -d "$cgroupDir/freezer" -o -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
|
||||||
echo "$(wrap_bad 'cgroup hierarchy' 'nonexistent??')"
|
wrap_bad 'cgroup hierarchy' 'nonexistent??'
|
||||||
fi
|
fi
|
||||||
echo " $(wrap_color '(see https://github.com/tianon/cgroupfs-mount)' yellow)"
|
wrap_color ' (see https://github.com/tianon/cgroupfs-mount)' yellow
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$(cat /sys/module/apparmor/parameters/enabled 2>/dev/null)" = 'Y' ]; then
|
if [ "$(cat /sys/module/apparmor/parameters/enabled 2>/dev/null)" = 'Y' ]; then
|
||||||
echo -n '- '
|
echo -n '- '
|
||||||
if command -v apparmor_parser &>/dev/null; then
|
if command -v apparmor_parser &>/dev/null; then
|
||||||
echo "$(wrap_good 'apparmor' 'enabled and tools installed')"
|
wrap_good 'apparmor' 'enabled and tools installed'
|
||||||
else
|
else
|
||||||
echo "$(wrap_bad 'apparmor' 'enabled, but apparmor_parser missing')"
|
wrap_bad 'apparmor' 'enabled, but apparmor_parser missing'
|
||||||
echo -n ' '
|
echo -n ' '
|
||||||
if command -v apt-get &>/dev/null; then
|
if command -v apt-get &>/dev/null; then
|
||||||
echo "$(wrap_color '(use "apt-get install apparmor" to fix this)')"
|
wrap_color '(use "apt-get install apparmor" to fix this)' yellow
|
||||||
elif command -v yum &>/dev/null; then
|
elif command -v yum &>/dev/null; then
|
||||||
echo "$(wrap_color '(your best bet is "yum install apparmor-parser")')"
|
wrap_color '(your best bet is "yum install apparmor-parser")' yellow
|
||||||
else
|
else
|
||||||
echo "$(wrap_color '(look for an "apparmor" package for your distribution)')"
|
wrap_color '(look for an "apparmor" package for your distribution)' yellow
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -236,7 +245,7 @@ echo 'Optional Features:'
|
|||||||
if [ "$kernelMajor" -lt 5 ] || [ "$kernelMajor" -eq 5 -a "$kernelMinor" -le 8 ]; then
|
if [ "$kernelMajor" -lt 5 ] || [ "$kernelMajor" -eq 5 -a "$kernelMinor" -le 8 ]; then
|
||||||
check_flags MEMCG_SWAP_ENABLED
|
check_flags MEMCG_SWAP_ENABLED
|
||||||
if is_set MEMCG_SWAP && ! is_set MEMCG_SWAP_ENABLED; then
|
if is_set MEMCG_SWAP && ! is_set MEMCG_SWAP_ENABLED; then
|
||||||
echo " $(wrap_color '(note that cgroup swap accounting is not enabled in your kernel config, you can enable it by setting boot option "swapaccount=1")' bold black)"
|
wrap_color ' (note that cgroup swap accounting is not enabled in your kernel config, you can enable it by setting boot option "swapaccount=1")' bold black
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user