-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdocker_pre-install-hn
executable file
·61 lines (45 loc) · 1.44 KB
/
docker_pre-install-hn
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
MODPROBE_FILE="/etc/sysconfig/modules/docker.modules"
MODULE_LIST="veth"
VZLIST="/usr/sbin/vzlist"
VZCTL="/usr/sbin/vzctl"
VERSION=1
VEROOT=$1
VEID=$2
function error_msg() {
echo $*
exit 1
}
function setup_modprobe() {
cat << EOF > $MODPROBE_FILE 2>/dev/null
#!/bin/sh
VERSION=$VERSION
MODULE_LIST="$MODULE_LIST"
for module in \$MODULE_LIST; do
modprobe -b \$module > /dev/null 2>&1
done
exit 0
EOF
[ $? -ne 0 ] && error_msg "Failed to create $MODPROBE_FILE file"
chmod 0755 $MODPROBE_FILE > /dev/null 2>&1
[ $? -ne 0 ] && error_msg "Failed to make $MODPROBE_FILE executable"
}
# 1. Check for vzkernel supports docker - 7.0, already supported
# 2. Check for Container is ploop - 7.0, only ploops
# 3. Check for needed features
$VZLIST -H -o features $VEID 2>/dev/null | grep 'bridge:on' > /dev/null 2>&1
[ $? -ne 0 ] && error_msg "Failed to install docker template: feature bridge should be on"
$VZLIST -H -o netfilter $VEID 2>/dev/null | grep '^full' > /dev/null 2>&1
[ $? -ne 0 ] && error_msg "Failed to install docker template: netfilter should be full"
# 4. Setup docker-required modules autoload
if [ -x $MODPROBE_FILE ]; then
EXISTING_VERSION=`cat $MODPROBE_FILE | grep ^VERSION | sed "s,VERSION=,,g"`
[ -z $EXISTING_VERSION ] && EXISTING_VERSION=0
[ $EXISTING_VERSION -lt $VERSION ] && setup_modprobe
else
setup_modprobe
fi
# 5. Load modules
$MODPROBE_FILE
[ $? -ne 0 ] && error_msg "Failed to load required modules"
exit 0