3 # Allow environment variables to override grep and config
4 : ${CONFIG:=/proc/config.gz}
8 SETCOLOR_SUCCESS
="printf \\033[1;32m"
9 SETCOLOR_FAILURE
="printf \\033[1;31m"
10 SETCOLOR_WARNING
="printf \\033[1;33m"
11 SETCOLOR_NORMAL
="printf \\033[0;39m"
14 $GREP "$1=[y|m]" $CONFIG > /dev
/null
24 if [ $RES -eq 0 ]; then
25 $SETCOLOR_SUCCESS && echo "enabled" && $SETCOLOR_NORMAL
27 if [ ! -z "$mandatory" -a "$mandatory" = yes ]; then
28 $SETCOLOR_FAILURE && echo "required" && $SETCOLOR_NORMAL
30 $SETCOLOR_WARNING && echo "missing" && $SETCOLOR_NORMAL
35 if [ ! -f $CONFIG ]; then
36 echo "Kernel configuration not found at $CONFIG; searching..."
38 HEADERS_CONFIG
="/lib/modules/$KVER/build/.config"
39 BOOT_CONFIG
="/boot/config-$KVER"
40 [ -f "${HEADERS_CONFIG}" ] && CONFIG
=${HEADERS_CONFIG}
41 [ -f "${BOOT_CONFIG}" ] && CONFIG
=${BOOT_CONFIG}
42 if [ ! -f "$CONFIG" ]; then
43 MODULEFILE
=$
(modinfo
-k $KVER -n $MODNAME 2> /dev
/null
)
44 # don't want to modprobe, so give user a hint
45 # although scripts/extract-ikconfig could be used to extract contents without loading kernel module
46 # http://svn.pld-linux.org/trac/svn/browser/geninitrd/trunk/geninitrd?rev=12696#L327
49 if [ ! -f $CONFIG ]; then
50 echo "$(basename $0): unable to retrieve kernel configuration" >&2
52 if [ -f "$MODULEFILE" ]; then
53 echo "Try modprobe $MODNAME module, or" >&2
55 echo "Try recompiling with IKCONFIG_PROC, installing the kernel headers," >&2
56 echo "or specifying the kernel configuration path with:" >&2
57 echo " CONFIG=<path> $(basename $0)" >&2
60 echo "Kernel configuration found at $CONFIG"
64 echo "--- Namespaces ---"
65 echo -n "Namespaces: " && is_enabled CONFIG_NAMESPACES
yes
66 echo -n "Utsname namespace: " && is_enabled CONFIG_UTS_NS
67 echo -n "Ipc namespace: " && is_enabled CONFIG_IPC_NS
yes
68 echo -n "Pid namespace: " && is_enabled CONFIG_PID_NS
yes
69 echo -n "User namespace: " && is_enabled CONFIG_USER_NS
70 echo -n "Network namespace: " && is_enabled CONFIG_NET_NS
71 echo -n "Multiple /dev/pts instances: " && is_enabled DEVPTS_MULTIPLE_INSTANCES
73 echo "--- Control groups ---"
76 # print all mountpoints for cgroup filesystems
77 awk '$1 !~ /#/ && $3 == mp { print $2; } ; END { exit(0); } ' "mp=$1" "$2" ;
80 CGROUP_MNT_PATH
=`print_cgroups cgroup /proc/self/mounts | head -n 1`
81 KVER_MAJOR
=$
($GREP '^# Linux.*Kernel Configuration' $CONFIG | \
82 sed -r 's/.* ([0-9])\.[0-9]{1,2}\.[0-9]{1,3}.*/\1/')
83 if [ "$KVER_MAJOR" = "2" ]; then
84 KVER_MINOR
=$
($GREP '^# Linux.*Kernel Configuration' $CONFIG | \
85 sed -r 's/.* 2.6.([0-9]{2}).*/\1/')
87 KVER_MINOR
=$
($GREP '^# Linux.*Kernel Configuration' $CONFIG | \
88 sed -r 's/.* [0-9]\.([0-9]{1,3})\.[0-9]{1,3}.*/\1/')
91 echo -n "Cgroup: " && is_enabled CONFIG_CGROUPS
yes
93 if [ -f $CGROUP_MNT_PATH/cgroup.clone_children
]; then
94 echo -n "Cgroup clone_children flag: " &&
95 $SETCOLOR_SUCCESS && echo "enabled" && $SETCOLOR_NORMAL
97 echo -n "Cgroup namespace: " && is_enabled CONFIG_CGROUP_NS
yes
99 echo -n "Cgroup device: " && is_enabled CONFIG_CGROUP_DEVICE
100 echo -n "Cgroup sched: " && is_enabled CONFIG_CGROUP_SCHED
101 echo -n "Cgroup cpu account: " && is_enabled CONFIG_CGROUP_CPUACCT
102 echo -n "Cgroup memory controller: "
103 if [ $KVER_MAJOR -ge 3 -a $KVER_MINOR -ge 6 ]; then
104 is_enabled CONFIG_MEMCG
106 is_enabled CONFIG_CGROUP_MEM_RES_CTLR
108 is_set CONFIG_SMP
&& echo -n "Cgroup cpuset: " && is_enabled CONFIG_CPUSETS
111 echo -n "Veth pair device: " && is_enabled CONFIG_VETH
112 echo -n "Macvlan: " && is_enabled CONFIG_MACVLAN
113 echo -n "Vlan: " && is_enabled CONFIG_VLAN_8021Q
114 echo -n "File capabilities: " && \
115 ( [ "${KVER_MAJOR}" = 2 ] && [ ${KVER_MINOR} -lt 33 ] && \
116 is_enabled CONFIG_SECURITY_FILE_CAPABILITIES
) || \
117 ( ( [ "${KVER_MAJOR}" = "2" ] && [ ${KVER_MINOR} -gt 32 ] ) || \
118 [ ${KVER_MAJOR} -gt 2 ] && $SETCOLOR_SUCCESS && \
119 echo "enabled" && $SETCOLOR_NORMAL )
122 echo "Note : Before booting a new kernel, you can check its configuration"
123 echo "usage : CONFIG=/path/to/config $0"