3 # based on gentoo startup script from opnvz
9 VZ_MODULES
="vzmon vzdev vzdquota"
10 VZ_NET_MODULES
="vznetdev vzethdev"
11 VZ_MIGRATE_MODULES
="vzcpt vzrst"
14 MODPROBE
="/sbin/modprobe"
17 VPSCONFDIR
="/etc/vz/conf"
19 VZCTL
="/usr/sbin/vzctl"
20 VZQUOTA
="/usr/sbin/vzquota"
25 stat_busy
"Setting up network for OpenVZ"
27 for mod
in ${VZ_NET_MODULES}; do
28 ${MODPROBE} $mod 2> /dev
/null
31 ${IP} link
set ${VZDEV} up
32 ${IP} addr add
0.0.0.0/0 dev
${VZDEV}
33 ${SYSCTL} -q -w net.ipv4.conf.
${VZDEV}.send_redirects
=0
41 $IP link
set ${VZDEV} down
2> /dev
/null
43 for mod
in ${VZ_NET_MODULES}; do
44 ${MODPROBE} -r $mod &> /dev
/null
52 velist
=$
(grep -l '^ONBOOT=yes\|^ONBOOT=\"yes\"' [0-9]*.conf
2>/dev
/null |
sed -e 's/.conf//g' |
sort -n)
55 ${SYSCTL} -q -w net.ipv4.route.src_check
=0
57 for veid
in ${velist}; do
58 stat_busy
"Starting VE ${veid}"
60 ${VZCTL} start
${veid} &> /dev
/null
75 if [ ! -f /proc
/vz
/veinfo
]; then
79 velist
=$
(awk '$1 != 0 {print $1}' /proc
/vz
/veinfo |
sort -nr)
81 for veid
in ${velist}; do
82 stat_bkgd
"Stopping VE ${veid}"
84 ${VZCTL} set ${veid} --cpuunits 2000 --cpulimit 0 &> /dev
/null
85 ${VZCTL} stop
${veid} &> /dev
/null
&
88 # wait for ve's to stop
89 for veid
in ${velist}; do
91 velist
=$
(awk '$1 != 0 {print $1}' /proc
/vz
/veinfo |
sort -nr)
99 stat_busy
"Loading OpenVZ modules"
101 if [ -e /dev
/vzctl
]; then
102 echo "OpenVZ is already running."
108 for mod
in ${VZ_MODULES}; do
109 /sbin
/modprobe
-r $mod &> /dev
/null
110 /sbin
/modprobe
$mod &> /dev
/null
113 if [ ! -e /dev
/vzctl
]; then
118 for mod
in ${VZ_MIGRATE_MODULES}; do
119 /sbin
/modprobe
-r $mod &> /dev
/null
120 /sbin
/modprobe
$mod &> /dev
/null
128 stat_busy
"Starting OpenVZ"
134 # network modules removed here
137 for mod
in ${VZ_MIGRATE_MODULES} ${VZ_MODULES}; do
138 /sbin
/modprobe
-r $mod &> /dev
/null
141 stat_busy
"Stopping OpenVZ"
151 echo "usage: $0 {start|stop|restart}"