mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Add more color and cgroupfs hierarchy verification to check-config.sh
Docker-DCO-1.1-Signed-off-by: Andrew Page <admwiggin@gmail.com> (github: tianon)
This commit is contained in:
parent
93bb208164
commit
aec989bd08
1 changed files with 75 additions and 36 deletions
|
@ -7,62 +7,101 @@ set -e
|
||||||
: ${CONFIG:=/proc/config.gz}
|
: ${CONFIG:=/proc/config.gz}
|
||||||
: ${GREP:=zgrep}
|
: ${GREP:=zgrep}
|
||||||
|
|
||||||
if [ ! -e "$CONFIG" ]; then
|
|
||||||
echo >&2 "warning: $CONFIG does not exist, searching other paths for kernel config..."
|
|
||||||
if [ -e "/boot/config-$(uname -r)" ]; then
|
|
||||||
CONFIG="/boot/config-$(uname -r)"
|
|
||||||
elif [ -e '/usr/src/linux/.config' ]; then
|
|
||||||
CONFIG='/usr/src/linux/.config'
|
|
||||||
else
|
|
||||||
echo >&2 "error: cannot find kernel config"
|
|
||||||
echo >&2 " try running this script again, specifying the kernel config:"
|
|
||||||
echo >&2 " CONFIG=/path/to/kernel/.config $0"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
is_set() {
|
is_set() {
|
||||||
$GREP "CONFIG_$1=[y|m]" $CONFIG > /dev/null
|
$GREP "CONFIG_$1=[y|m]" $CONFIG > /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# see http://en.wikipedia.org/wiki/ANSI_escape_code#Colors
|
||||||
|
declare -A colors=(
|
||||||
|
[black]=30
|
||||||
|
[red]=31
|
||||||
|
[green]=32
|
||||||
|
[yellow]=33
|
||||||
|
[blue]=34
|
||||||
|
[magenta]=35
|
||||||
|
[cyan]=36
|
||||||
|
[white]=37
|
||||||
|
)
|
||||||
color() {
|
color() {
|
||||||
color=
|
color=()
|
||||||
prefix=
|
|
||||||
if [ "$1" = 'bold' ]; then
|
if [ "$1" = 'bold' ]; then
|
||||||
prefix='1;'
|
color+=( '1' )
|
||||||
shift
|
shift
|
||||||
fi
|
fi
|
||||||
case "$1" in
|
if [ $# -gt 0 ] && [ "${colors[$1]}" ]; then
|
||||||
green) color='32' ;;
|
color+=( "${colors[$1]}" )
|
||||||
red) color='31' ;;
|
fi
|
||||||
gray) color='30' ;;
|
local IFS=';'
|
||||||
reset) color='' ;;
|
echo -en '\033['"${color[*]}"m
|
||||||
esac
|
}
|
||||||
echo -en '\033['"$prefix$color"m
|
wrap_color() {
|
||||||
|
text="$1"
|
||||||
|
shift
|
||||||
|
color "$@"
|
||||||
|
echo -n "$text"
|
||||||
|
color reset
|
||||||
|
echo
|
||||||
|
}
|
||||||
|
|
||||||
|
wrap_good() {
|
||||||
|
echo "$(wrap_color "$1" white): $(wrap_color "$2" green)"
|
||||||
|
}
|
||||||
|
wrap_bad() {
|
||||||
|
echo "$(wrap_color "$1" bold): $(wrap_color "$2" bold red)"
|
||||||
|
}
|
||||||
|
wrap_warning() {
|
||||||
|
wrap_color >&2 "$*" red
|
||||||
}
|
}
|
||||||
|
|
||||||
check_flag() {
|
check_flag() {
|
||||||
if is_set "$1"; then
|
if is_set "$1"; then
|
||||||
color green
|
wrap_good "CONFIG_$1" 'enabled'
|
||||||
echo -n enabled
|
|
||||||
else
|
else
|
||||||
color bold red
|
wrap_bad "CONFIG_$1" 'missing'
|
||||||
echo -n missing
|
|
||||||
fi
|
fi
|
||||||
color reset
|
|
||||||
}
|
}
|
||||||
|
|
||||||
check_flags() {
|
check_flags() {
|
||||||
for flag in "$@"; do
|
for flag in "$@"; do
|
||||||
echo "- CONFIG_$flag: $(check_flag "$flag")"
|
echo "- $(check_flag "$flag")"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if [ ! -e "$CONFIG" ]; then
|
||||||
|
wrap_warning "warning: $CONFIG does not exist, searching other paths for kernel config..."
|
||||||
|
for tryConfig in \
|
||||||
|
'/proc/config.gz' \
|
||||||
|
"/boot/config-$(uname -r)" \
|
||||||
|
'/usr/src/linux/.config' \
|
||||||
|
; do
|
||||||
|
if [ -e "$tryConfig" ]; then
|
||||||
|
CONFIG="$tryConfig"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [ ! -e "$CONFIG" ]; then
|
||||||
|
wrap_warning "error: cannot find kernel config"
|
||||||
|
wrap_warning " try running this script again, specifying the kernel config:"
|
||||||
|
wrap_warning " CONFIG=/path/to/kernel/.config $0"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
wrap_color "info: reading kernel config from $CONFIG ..." white
|
||||||
echo
|
echo
|
||||||
|
|
||||||
# TODO check that the cgroupfs hierarchy is properly mounted
|
|
||||||
|
|
||||||
echo 'Generally Necessary:'
|
echo 'Generally Necessary:'
|
||||||
|
|
||||||
|
echo -n '- '
|
||||||
|
cgroupCpuDir="$(awk '/[, ]cpu[, ]/ && $8 == "cgroup" { print $5 }' /proc/$$/mountinfo | head -n1)"
|
||||||
|
cgroupDir="$(dirname "$cgroupCpuDir")"
|
||||||
|
if [ -d "$cgroupDir/cpu" ]; then
|
||||||
|
echo "$(wrap_good 'cgroup hierarchy' 'properly mounted') [$cgroupDir]"
|
||||||
|
else
|
||||||
|
echo "$(wrap_bad 'cgroup hierarchy' 'single mountpoint!') [$cgroupCpuDir]"
|
||||||
|
echo " $(wrap_color '(see https://github.com/tianon/cgroupfs-mount)' yellow)"
|
||||||
|
fi
|
||||||
|
|
||||||
flags=(
|
flags=(
|
||||||
NAMESPACES {NET,PID,IPC,UTS}_NS
|
NAMESPACES {NET,PID,IPC,UTS}_NS
|
||||||
DEVPTS_MULTIPLE_INSTANCES
|
DEVPTS_MULTIPLE_INSTANCES
|
||||||
|
@ -83,16 +122,16 @@ check_flags "${flags[@]}"
|
||||||
|
|
||||||
echo '- Storage Drivers:'
|
echo '- Storage Drivers:'
|
||||||
{
|
{
|
||||||
echo '- "aufs":'
|
echo '- "'$(wrap_color 'aufs' blue)'":'
|
||||||
check_flags AUFS_FS | sed 's/^/ /'
|
check_flags AUFS_FS | sed 's/^/ /'
|
||||||
if ! is_set AUFS_FS && grep -q aufs /proc/filesystems; then
|
if ! is_set AUFS_FS && grep -q aufs /proc/filesystems; then
|
||||||
echo " $(color bold gray)(note that some kernels include AUFS patches but not the AUFS_FS flag)$(color reset)"
|
echo " $(wrap_color '(note that some kernels include AUFS patches but not the AUFS_FS flag)' bold black)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo '- "btrfs":'
|
echo '- "'$(wrap_color 'btrfs' blue)'":'
|
||||||
check_flags BTRFS_FS | sed 's/^/ /'
|
check_flags BTRFS_FS | sed 's/^/ /'
|
||||||
|
|
||||||
echo '- "devicemapper":'
|
echo '- "'$(wrap_color 'devicemapper' blue)'":'
|
||||||
check_flags BLK_DEV_DM DM_THIN_PROVISIONING EXT4_FS | sed 's/^/ /'
|
check_flags BLK_DEV_DM DM_THIN_PROVISIONING EXT4_FS | sed 's/^/ /'
|
||||||
} | sed 's/^/ /'
|
} | sed 's/^/ /'
|
||||||
echo
|
echo
|
||||||
|
|
Loading…
Add table
Reference in a new issue