]> git.proxmox.com Git - mirror_lxc.git/blame - src/lxc/lxc-checkconfig.in
ovl_rsync: make sure to umount
[mirror_lxc.git] / src / lxc / lxc-checkconfig.in
CommitLineData
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
8SETCOLOR_SUCCESS="printf \\033[1;32m"
9SETCOLOR_FAILURE="printf \\033[1;31m"
10SETCOLOR_WARNING="printf \\033[1;33m"
11SETCOLOR_NORMAL="printf \\033[0;39m"
22e761af 12
ef184f8c 13is_set() {
0c69c79b 14 $GREP "$1=[y|m]" $CONFIG > /dev/null
ef184f8c
DL
15 return $?
16}
17
22e761af 18is_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 35if [ ! -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 62fi
63
64echo "--- Namespaces ---"
65echo -n "Namespaces: " && is_enabled CONFIG_NAMESPACES yes
66echo -n "Utsname namespace: " && is_enabled CONFIG_UTS_NS
67echo -n "Ipc namespace: " && is_enabled CONFIG_IPC_NS yes
68echo -n "Pid namespace: " && is_enabled CONFIG_PID_NS yes
69echo -n "User namespace: " && is_enabled CONFIG_USER_NS
70echo -n "Network namespace: " && is_enabled CONFIG_NET_NS
8de09ef5 71echo -n "Multiple /dev/pts instances: " && is_enabled DEVPTS_MULTIPLE_INSTANCES
22e761af 72echo
73echo "--- Control groups ---"
d9e2cc0e 74
3e2981d4
SH
75print_cgroups() {
76 # print all mountpoints for cgroup filesystems
77 awk '$1 !~ /#/ && $3 == mp { print $2; } ; END { exit(0); } ' "mp=$1" "$2" ;
78}
79
1d1774b1 80CGROUP_MNT_PATH=`print_cgroups cgroup /proc/self/mounts | head -n 1`
8525b5e5 81KVER_MAJOR=$($GREP '^# Linux.*Kernel Configuration' $CONFIG | \
c93c7b1a 82 sed -r 's/.* ([0-9])\.[0-9]{1,2}\.[0-9]{1,3}.*/\1/')
7ec3fa71 83if [ "$KVER_MAJOR" = "2" ]; then
8525b5e5 84KVER_MINOR=$($GREP '^# Linux.*Kernel Configuration' $CONFIG | \
c93c7b1a
DE
85 sed -r 's/.* 2.6.([0-9]{2}).*/\1/')
86else
8525b5e5 87KVER_MINOR=$($GREP '^# Linux.*Kernel Configuration' $CONFIG | \
c93c7b1a
DE
88 sed -r 's/.* [0-9]\.([0-9]{1,3})\.[0-9]{1,3}.*/\1/')
89fi
d9e2cc0e 90
ef184f8c 91echo -n "Cgroup: " && is_enabled CONFIG_CGROUPS yes
d9e2cc0e
DL
92
93if [ -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
96else
97 echo -n "Cgroup namespace: " && is_enabled CONFIG_CGROUP_NS yes
98fi
22e761af 99echo -n "Cgroup device: " && is_enabled CONFIG_CGROUP_DEVICE
100echo -n "Cgroup sched: " && is_enabled CONFIG_CGROUP_SCHED
101echo -n "Cgroup cpu account: " && is_enabled CONFIG_CGROUP_CPUACCT
f79d43bb 102echo -n "Cgroup memory controller: "
56983b40 103if ([ $KVER_MAJOR -ge 3 ] && [ $KVER_MINOR -ge 6 ]) || ([ $KVER_MAJOR -gt 3 ]); then
c93c7b1a
DE
104 is_enabled CONFIG_MEMCG
105else
106 is_enabled CONFIG_CGROUP_MEM_RES_CTLR
107fi
ef184f8c 108is_set CONFIG_SMP && echo -n "Cgroup cpuset: " && is_enabled CONFIG_CPUSETS
22e761af 109echo
110echo "--- Misc ---"
111echo -n "Veth pair device: " && is_enabled CONFIG_VETH
112echo -n "Macvlan: " && is_enabled CONFIG_MACVLAN
26c39028 113echo -n "Vlan: " && is_enabled CONFIG_VLAN_8021Q
aee755ee
TA
114echo -n "Bridges: " && is_enabled CONFIG_BRIDGE
115echo -n "Advanced netfilter: " && is_enabled CONFIG_NETFILTER_ADVANCED
116echo -n "CONFIG_NF_NAT_IPV4: " && is_enabled CONFIG_NF_NAT_IPV4
117echo -n "CONFIG_NF_NAT_IPV6: " && is_enabled CONFIG_NF_NAT_IPV6
118echo -n "CONFIG_IP_NF_TARGET_MASQUERADE: " && is_enabled CONFIG_IP_NF_TARGET_MASQUERADE
119echo -n "CONFIG_IP6_NF_TARGET_MASQUERADE: " && is_enabled CONFIG_IP6_NF_TARGET_MASQUERADE
120echo -n "CONFIG_NETFILTER_XT_TARGET_CHECKSUM: " && is_enabled CONFIG_NETFILTER_XT_TARGET_CHECKSUM
121
122echo
123echo "--- Checkpoint/Restore ---"
124echo -n "checkpoint restore: " && is_enabled CONFIG_CHECKPOINT_RESTORE
125echo -n "CONFIG_FHANDLE: " && is_enabled CONFIG_FHANDLE
126echo -n "CONFIG_EVENTFD: " && is_enabled CONFIG_EVENTFD
127echo -n "CONFIG_EPOLL: " && is_enabled CONFIG_EPOLL
128echo -n "CONFIG_UNIX_DIAG: " && is_enabled CONFIG_UNIX_DIAG
129echo -n "CONFIG_INET_DIAG: " && is_enabled CONFIG_INET_DIAG
130echo -n "CONFIG_PACKET_DIAG: " && is_enabled CONFIG_PACKET_DIAG
131echo -n "CONFIG_NETLINK_DIAG: " && is_enabled CONFIG_NETLINK_DIAG
132
7ec3fa71
NC
133echo -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
140echo
141echo "Note : Before booting a new kernel, you can check its configuration"
142echo "usage : CONFIG=/path/to/config $0"
143echo
144