]>
Commit | Line | Data |
---|---|---|
7ec3fa71 | 1 | #!/bin/sh |
dbdab2ff GT |
2 | |
3 | # Allow environment variables to override grep and config | |
4 | : ${CONFIG:=/proc/config.gz} | |
5 | : ${GREP:=zgrep} | |
8111adfd | 6 | : ${MODNAME:=configs} |
22e761af | 7 | |
bc2333eb NC |
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" | |
22e761af | 12 | |
ef184f8c | 13 | is_set() { |
0c69c79b | 14 | $GREP "$1=[y|m]" $CONFIG > /dev/null |
ef184f8c DL |
15 | return $? |
16 | } | |
17 | ||
22e761af | 18 | is_enabled() { |
19 | mandatory=$2 | |
ef184f8c DL |
20 | |
21 | is_set $1 | |
22e761af | 22 | RES=$? |
23 | ||
3f9cf2ad | 24 | if [ $RES -eq 0 ]; then |
14d9c0f0 | 25 | $SETCOLOR_SUCCESS && echo "enabled" && $SETCOLOR_NORMAL |
22e761af | 26 | else |
56983b40 | 27 | if [ ! -z "$mandatory" ] && [ "$mandatory" = yes ]; then |
14d9c0f0 SG |
28 | $SETCOLOR_FAILURE && echo "required" && $SETCOLOR_NORMAL |
29 | else | |
30 | $SETCOLOR_WARNING && echo "missing" && $SETCOLOR_NORMAL | |
31 | fi | |
22e761af | 32 | fi |
33 | } | |
34 | ||
7e7f51d1 | 35 | if [ ! -f $CONFIG ]; then |
2775bb4c | 36 | echo "Kernel configuration not found at $CONFIG; searching..." |
7e7f51d1 | 37 | KVER="`uname -r`" |
84a15642 GT |
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} | |
8111adfd SG |
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 | |
ec64264d | 45 | # although scripts/extract-ikconfig could be used to extract contents without loading kernel module |
8111adfd SG |
46 | # http://svn.pld-linux.org/trac/svn/browser/geninitrd/trunk/geninitrd?rev=12696#L327 |
47 | fi | |
7e7f51d1 KH |
48 | GREP=grep |
49 | if [ ! -f $CONFIG ]; then | |
2775bb4c DW |
50 | echo "$(basename $0): unable to retrieve kernel configuration" >&2 |
51 | echo >&2 | |
8111adfd SG |
52 | if [ -f "$MODULEFILE" ]; then |
53 | echo "Try modprobe $MODNAME module, or" >&2 | |
54 | fi | |
2775bb4c DW |
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 | |
7e7f51d1 | 58 | exit 1 |
dbdab2ff | 59 | else |
2775bb4c | 60 | echo "Kernel configuration found at $CONFIG" |
7e7f51d1 | 61 | fi |
22e761af | 62 | fi |
63 | ||
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 | |
8de09ef5 | 71 | echo -n "Multiple /dev/pts instances: " && is_enabled DEVPTS_MULTIPLE_INSTANCES |
22e761af | 72 | echo |
73 | echo "--- Control groups ---" | |
d9e2cc0e | 74 | |
3e2981d4 SH |
75 | print_cgroups() { |
76 | # print all mountpoints for cgroup filesystems | |
77 | awk '$1 !~ /#/ && $3 == mp { print $2; } ; END { exit(0); } ' "mp=$1" "$2" ; | |
78 | } | |
79 | ||
1d1774b1 | 80 | CGROUP_MNT_PATH=`print_cgroups cgroup /proc/self/mounts | head -n 1` |
8525b5e5 | 81 | KVER_MAJOR=$($GREP '^# Linux.*Kernel Configuration' $CONFIG | \ |
c93c7b1a | 82 | sed -r 's/.* ([0-9])\.[0-9]{1,2}\.[0-9]{1,3}.*/\1/') |
7ec3fa71 | 83 | if [ "$KVER_MAJOR" = "2" ]; then |
8525b5e5 | 84 | KVER_MINOR=$($GREP '^# Linux.*Kernel Configuration' $CONFIG | \ |
c93c7b1a DE |
85 | sed -r 's/.* 2.6.([0-9]{2}).*/\1/') |
86 | else | |
8525b5e5 | 87 | KVER_MINOR=$($GREP '^# Linux.*Kernel Configuration' $CONFIG | \ |
c93c7b1a DE |
88 | sed -r 's/.* [0-9]\.([0-9]{1,3})\.[0-9]{1,3}.*/\1/') |
89 | fi | |
d9e2cc0e | 90 | |
ef184f8c | 91 | echo -n "Cgroup: " && is_enabled CONFIG_CGROUPS yes |
d9e2cc0e DL |
92 | |
93 | if [ -f $CGROUP_MNT_PATH/cgroup.clone_children ]; then | |
94 | echo -n "Cgroup clone_children flag: " && | |
7ec3fa71 | 95 | $SETCOLOR_SUCCESS && echo "enabled" && $SETCOLOR_NORMAL |
d9e2cc0e DL |
96 | else |
97 | echo -n "Cgroup namespace: " && is_enabled CONFIG_CGROUP_NS yes | |
98 | fi | |
22e761af | 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 | |
f79d43bb | 102 | echo -n "Cgroup memory controller: " |
56983b40 | 103 | if ([ $KVER_MAJOR -ge 3 ] && [ $KVER_MINOR -ge 6 ]) || ([ $KVER_MAJOR -gt 3 ]); then |
c93c7b1a DE |
104 | is_enabled CONFIG_MEMCG |
105 | else | |
106 | is_enabled CONFIG_CGROUP_MEM_RES_CTLR | |
107 | fi | |
ef184f8c | 108 | is_set CONFIG_SMP && echo -n "Cgroup cpuset: " && is_enabled CONFIG_CPUSETS |
22e761af | 109 | echo |
110 | echo "--- Misc ---" | |
111 | echo -n "Veth pair device: " && is_enabled CONFIG_VETH | |
112 | echo -n "Macvlan: " && is_enabled CONFIG_MACVLAN | |
26c39028 | 113 | echo -n "Vlan: " && is_enabled CONFIG_VLAN_8021Q |
aee755ee TA |
114 | echo -n "Bridges: " && is_enabled CONFIG_BRIDGE |
115 | echo -n "Advanced netfilter: " && is_enabled CONFIG_NETFILTER_ADVANCED | |
116 | echo -n "CONFIG_NF_NAT_IPV4: " && is_enabled CONFIG_NF_NAT_IPV4 | |
117 | echo -n "CONFIG_NF_NAT_IPV6: " && is_enabled CONFIG_NF_NAT_IPV6 | |
118 | echo -n "CONFIG_IP_NF_TARGET_MASQUERADE: " && is_enabled CONFIG_IP_NF_TARGET_MASQUERADE | |
119 | echo -n "CONFIG_IP6_NF_TARGET_MASQUERADE: " && is_enabled CONFIG_IP6_NF_TARGET_MASQUERADE | |
120 | echo -n "CONFIG_NETFILTER_XT_TARGET_CHECKSUM: " && is_enabled CONFIG_NETFILTER_XT_TARGET_CHECKSUM | |
121 | ||
122 | echo | |
123 | echo "--- Checkpoint/Restore ---" | |
124 | echo -n "checkpoint restore: " && is_enabled CONFIG_CHECKPOINT_RESTORE | |
125 | echo -n "CONFIG_FHANDLE: " && is_enabled CONFIG_FHANDLE | |
126 | echo -n "CONFIG_EVENTFD: " && is_enabled CONFIG_EVENTFD | |
127 | echo -n "CONFIG_EPOLL: " && is_enabled CONFIG_EPOLL | |
128 | echo -n "CONFIG_UNIX_DIAG: " && is_enabled CONFIG_UNIX_DIAG | |
129 | echo -n "CONFIG_INET_DIAG: " && is_enabled CONFIG_INET_DIAG | |
130 | echo -n "CONFIG_PACKET_DIAG: " && is_enabled CONFIG_PACKET_DIAG | |
131 | echo -n "CONFIG_NETLINK_DIAG: " && is_enabled CONFIG_NETLINK_DIAG | |
132 | ||
7ec3fa71 NC |
133 | echo -n "File capabilities: " && \ |
134 | ( [ "${KVER_MAJOR}" = 2 ] && [ ${KVER_MINOR} -lt 33 ] && \ | |
135 | is_enabled CONFIG_SECURITY_FILE_CAPABILITIES ) || \ | |
136 | ( ( [ "${KVER_MAJOR}" = "2" ] && [ ${KVER_MINOR} -gt 32 ] ) || \ | |
137 | [ ${KVER_MAJOR} -gt 2 ] && $SETCOLOR_SUCCESS && \ | |
138 | echo "enabled" && $SETCOLOR_NORMAL ) | |
8208b295 GZ |
139 | |
140 | echo | |
141 | echo "Note : Before booting a new kernel, you can check its configuration" | |
142 | echo "usage : CONFIG=/path/to/config $0" | |
143 | echo | |
144 |