From 9c0c4aeda47fcebc4470f7ba786749af2999ec78 Mon Sep 17 00:00:00 2001 From: Tianon Gravi Date: Tue, 1 Apr 2014 17:42:54 -0600 Subject: [PATCH] Add basic initial "check-config" script to contrib Docker-DCO-1.1-Signed-off-by: Andrew Page (github: tianon) --- contrib/check-config.sh | 102 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100755 contrib/check-config.sh diff --git a/contrib/check-config.sh b/contrib/check-config.sh new file mode 100755 index 0000000000..62606aca04 --- /dev/null +++ b/contrib/check-config.sh @@ -0,0 +1,102 @@ +#!/usr/bin/env bash +set -e + +# bits of this were adapted from lxc-checkconfig +# see also https://github.com/lxc/lxc/blob/lxc-1.0.2/src/lxc/lxc-checkconfig.in + +: ${CONFIG:=/proc/config.gz} +: ${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() { + $GREP "CONFIG_$1=[y|m]" $CONFIG > /dev/null +} + +color() { + color= + prefix= + if [ "$1" = 'bold' ]; then + prefix='1;' + shift + fi + case "$1" in + green) color='32' ;; + red) color='31' ;; + gray) color='30' ;; + reset) color='' ;; + esac + echo -en '\033['"$prefix$color"m +} + +check_flag() { + if is_set "$1"; then + color green + echo -n enabled + else + color bold red + echo -n missing + fi + color reset +} + +check_flags() { + for flag in "$@"; do + echo "- CONFIG_$flag: $(check_flag "$flag")" + done +} + +echo + +# TODO check that the cgroupfs hierarchy is properly mounted + +echo 'Generally Necessary:' +flags=( + NAMESPACES {NET,PID,IPC,UTS}_NS + DEVPTS_MULTIPLE_INSTANCES + CGROUPS CGROUP_DEVICE + MACVLAN VETH BRIDGE + IP_NF_TARGET_MASQUERADE NETFILTER_XT_MATCH_{ADDRTYPE,CONNTRACK} + NF_NAT NF_NAT_NEEDED +) +check_flags "${flags[@]}" +echo + +echo 'Optional Features:' +flags=( + MEMCG_SWAP + RESOURCE_COUNTERS +) +check_flags "${flags[@]}" + +echo '- Storage Drivers:' +{ + echo '- "aufs":' + check_flags AUFS_FS | sed 's/^/ /' + 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)" + fi + + echo '- "btrfs":' + check_flags BTRFS_FS | sed 's/^/ /' + + echo '- "devicemapper":' + check_flags BLK_DEV_DM DM_THIN_PROVISIONING EXT4_FS | sed 's/^/ /' +} | sed 's/^/ /' +echo + +#echo 'Potential Future Features:' +#check_flags USER_NS +#echo