Annotation of /trunk/vzctl/patches/vzctl-3.0.18-magellan.patch
Parent Directory | Revision Log
Revision 274 -
(hide annotations)
(download)
Sat Jul 21 22:55:33 2007 UTC (17 years, 2 months ago) by niro
File size: 23015 byte(s)
Sat Jul 21 22:55:33 2007 UTC (17 years, 2 months ago) by niro
File size: 23015 byte(s)
-fixed patch to recognite install-magellan target
1 | niro | 273 | diff -Naur vzctl-3.0.18/etc/dists/magellan.conf vzctl-3.0.18-magellan/etc/dists/magellan.conf |
2 | --- vzctl-3.0.18/etc/dists/magellan.conf 1970-01-01 01:00:00.000000000 +0100 | ||
3 | +++ vzctl-3.0.18-magellan/etc/dists/magellan.conf 2007-07-22 00:44:53.000000000 +0200 | ||
4 | @@ -0,0 +1,27 @@ | ||
5 | +# Copyright (C) 2000-2007 SWsoft. All rights reserved. | ||
6 | +# | ||
7 | +# This program is free software; you can redistribute it and/or modify | ||
8 | +# it under the terms of the GNU General Public License as published by | ||
9 | +# the Free Software Foundation; either version 2 of the License, or | ||
10 | +# (at your option) any later version. | ||
11 | +# | ||
12 | +# This program is distributed in the hope that it will be useful, | ||
13 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | +# GNU General Public License for more details. | ||
16 | +# | ||
17 | +# You should have received a copy of the GNU General Public License | ||
18 | +# along with this program; if not, write to the Free Software | ||
19 | +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
20 | +# | ||
21 | +# This configuration file is meant to be used with | ||
22 | +# the Magellan distribution kit. | ||
23 | +# | ||
24 | + | ||
25 | +ADD_IP=magellan-add_ip.sh | ||
26 | +DEL_IP=magellan-del_ip.sh | ||
27 | +SET_HOSTNAME=magellan-set_hostname.sh | ||
28 | +SET_DNS=set_dns.sh | ||
29 | +SET_USERPASS=set_userpass.sh | ||
30 | +SET_UGID_QUOTA=magellan-set_ugid_quota.sh | ||
31 | +POST_CREATE=postcreate.sh | ||
32 | diff -Naur vzctl-3.0.18/etc/dists/scripts/magellan-add_ip.sh vzctl-3.0.18-magellan/etc/dists/scripts/magellan-add_ip.sh | ||
33 | --- vzctl-3.0.18/etc/dists/scripts/magellan-add_ip.sh 1970-01-01 01:00:00.000000000 +0100 | ||
34 | +++ vzctl-3.0.18-magellan/etc/dists/scripts/magellan-add_ip.sh 2007-07-22 00:45:06.000000000 +0200 | ||
35 | @@ -0,0 +1,122 @@ | ||
36 | +#!/bin/bash | ||
37 | +# Copyright (C) 2000-2007 SWsoft. All rights reserved. | ||
38 | +# | ||
39 | +# This program is free software; you can redistribute it and/or modify | ||
40 | +# it under the terms of the GNU General Public License as published by | ||
41 | +# the Free Software Foundation; either version 2 of the License, or | ||
42 | +# (at your option) any later version. | ||
43 | +# | ||
44 | +# This program is distributed in the hope that it will be useful, | ||
45 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
46 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
47 | +# GNU General Public License for more details. | ||
48 | +# | ||
49 | +# You should have received a copy of the GNU General Public License | ||
50 | +# along with this program; if not, write to the Free Software | ||
51 | +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
52 | +# | ||
53 | +# | ||
54 | +# This script configure IP alias(es) inside Magellan like VE. | ||
55 | +# | ||
56 | +# Parameters are passed in environment variables. | ||
57 | +# Required parameters: | ||
58 | +# IP_ADDR - IP address(es) to add | ||
59 | +# (several addresses should be divided by space) | ||
60 | +# Optional parameters: | ||
61 | +# VE_STATE - state of VE; could be one of: | ||
62 | +# starting | stopping | running | stopped | ||
63 | +# IPDELALL - delete all old interfaces | ||
64 | +# | ||
65 | + | ||
66 | +VENET_DEV=venet0 | ||
67 | +IFCFG_DIR=/etc/conf.d | ||
68 | +IFCFG=${IFCFG_DIR}/net.${VENET_DEV} | ||
69 | +ROUTESCFG=${IFCFG_DIR}/net.routes | ||
70 | +SCRIPT=/etc/runlevels/default/net.${VENET_DEV} | ||
71 | +HOSTFILE=/etc/hosts | ||
72 | + | ||
73 | +function setup_network() | ||
74 | +{ | ||
75 | + cat > ${IFCFG} << EOF | ||
76 | +ONBOOT=yes | ||
77 | +NETWORKING=static | ||
78 | +IP=127.0.0.1 | ||
79 | +NETMASK=255.255.255.255 | ||
80 | +BROADCAST=0.0.0.0 | ||
81 | +EOF | ||
82 | + | ||
83 | + # setup routes | ||
84 | + echo "-net ${FAKEGATEWAY} netmask 255.255.255.255 dev ${VENET_DEV}" > ${ROUTESCFG} | ||
85 | + echo "default gw ${FAKEGATEWAY}" >> ${ROUTESCFG} | ||
86 | + | ||
87 | + # Set up /etc/hosts | ||
88 | + if [ ! -f ${HOSTFILE} ]; then | ||
89 | + echo "127.0.0.1 localhost.localdomain localhost" > $HOSTFILE | ||
90 | + fi | ||
91 | +} | ||
92 | + | ||
93 | +function get_all_aliasid() | ||
94 | +{ | ||
95 | + IFNUM=-1 | ||
96 | + IFNUMLIST=$(for i in $(find ${IFCFG_DIR} -name net.${VENET_DEV}:*); do echo $i | sed "s/.*${VENET_DEV}://"; done) | ||
97 | +} | ||
98 | + | ||
99 | +function get_free_aliasid() | ||
100 | +{ | ||
101 | + local found= | ||
102 | + | ||
103 | + [ -z "${IFNUMLIST}" ] && get_all_aliasid | ||
104 | + while test -z ${found}; do | ||
105 | + let IFNUM=IFNUM+1 | ||
106 | + echo "${IFNUMLIST}" | grep -q -E "${IFNUM}" 2>/dev/null || found=1 | ||
107 | + done | ||
108 | +} | ||
109 | + | ||
110 | +function create_config() | ||
111 | +{ | ||
112 | + local ip=$1 | ||
113 | + local ifnum=$2 | ||
114 | + | ||
115 | + echo -e "# auto-generated configuration for ${VENET_DEV}:${ifnum} | ||
116 | +ONBOOT=yes | ||
117 | +NETWORKING=static | ||
118 | +IP=${ip} | ||
119 | +NETMASK=255.255.255.255 | ||
120 | +BROADCAST=0.0.0.0 | ||
121 | +" > ${IFCFG}:${ifnum} | ||
122 | +} | ||
123 | + | ||
124 | + | ||
125 | +function add_ip() | ||
126 | +{ | ||
127 | + local ip | ||
128 | + local new_ips | ||
129 | + | ||
130 | + # In case we are starting VE | ||
131 | + if [ "x${VE_STATE}" = "xstarting" ]; then | ||
132 | + setup_network | ||
133 | + fi | ||
134 | + | ||
135 | + if [ "x${IPDELALL}" = "xyes" ]; then | ||
136 | + rm -f ${IFCFG} | ||
137 | + rm -f ${IFCFG}:[0-9]* | ||
138 | + fi | ||
139 | + | ||
140 | + for ip in ${IP_ADDR}; do | ||
141 | + found= | ||
142 | + if grep -e "\\<${ip}\\>" >/dev/null 2>&1 ${IFCFG}:*; then | ||
143 | + continue | ||
144 | + fi | ||
145 | + get_free_aliasid | ||
146 | + create_config ${ip} ${IFNUM} | ||
147 | + done | ||
148 | + | ||
149 | + if [ "x${VE_STATE}" = "xrunning" ]; then | ||
150 | + # synchronyze config files & interfaces | ||
151 | + /etc/init.d/network restart 2>/dev/null 1>/dev/null | ||
152 | + fi | ||
153 | +} | ||
154 | + | ||
155 | +add_ip | ||
156 | +exit 0 | ||
157 | +# end of script | ||
158 | diff -Naur vzctl-3.0.18/etc/dists/scripts/magellan-del_ip.sh vzctl-3.0.18-magellan/etc/dists/scripts/magellan-del_ip.sh | ||
159 | --- vzctl-3.0.18/etc/dists/scripts/magellan-del_ip.sh 1970-01-01 01:00:00.000000000 +0100 | ||
160 | +++ vzctl-3.0.18-magellan/etc/dists/scripts/magellan-del_ip.sh 2007-07-22 00:45:09.000000000 +0200 | ||
161 | @@ -0,0 +1,53 @@ | ||
162 | +#!/bin/bash | ||
163 | +# Copyright (C) 2000-2007 SWsoft. All rights reserved. | ||
164 | +# | ||
165 | +# This program is free software; you can redistribute it and/or modify | ||
166 | +# it under the terms of the GNU General Public License as published by | ||
167 | +# the Free Software Foundation; either version 2 of the License, or | ||
168 | +# (at your option) any later version. | ||
169 | +# | ||
170 | +# This program is distributed in the hope that it will be useful, | ||
171 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
172 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
173 | +# GNU General Public License for more details. | ||
174 | +# | ||
175 | +# You should have received a copy of the GNU General Public License | ||
176 | +# along with this program; if not, write to the Free Software | ||
177 | +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
178 | +# | ||
179 | +# | ||
180 | +# This script deletes IP alias(es) inside VE for Magellan like distros. | ||
181 | +# For usage info see ve-alias_del(5) man page. | ||
182 | +# | ||
183 | +# Parameters are passed in environment variables. | ||
184 | +# Required parameters: | ||
185 | +# IP_ADDR - IPs to delete, several addresses should be divided by space | ||
186 | +# Optional parameters: | ||
187 | +# VE_STATE - state of VE; could be one of: | ||
188 | +# starting | stopping | running | stopped | ||
189 | + | ||
190 | +VENET_DEV=venet0 | ||
191 | +IFCFG_DIR=/etc/conf.d | ||
192 | +IFCFG=${IFCFG_DIR}/net.${VENET_DEV} | ||
193 | + | ||
194 | +function del_ip() | ||
195 | +{ | ||
196 | + local found= | ||
197 | + local ip ifname | ||
198 | + | ||
199 | + for ip in ${IP_ADDR}; do | ||
200 | + ifname=$(grep -l -e "\\<${ip}\\>" ${IFCFG}:* | sed "s:${IFCFG_DIR}:net.::") | ||
201 | + if [ -n "${ifname}" ]; then | ||
202 | + ifconfig ${ifname} down | ||
203 | + rm -f ${IFCFG_DIR}/net.${ifname} | ||
204 | + found=true | ||
205 | + fi | ||
206 | + done | ||
207 | + if [ -n "${found}" ]; then | ||
208 | + /etc/init.d/network restart 2>/dev/null 1>/dev/null | ||
209 | + fi | ||
210 | +} | ||
211 | + | ||
212 | +del_ip | ||
213 | +exit 0 | ||
214 | +# end of script | ||
215 | diff -Naur vzctl-3.0.18/etc/dists/scripts/magellan-set_hostname.sh vzctl-3.0.18-magellan/etc/dists/scripts/magellan-set_hostname.sh | ||
216 | --- vzctl-3.0.18/etc/dists/scripts/magellan-set_hostname.sh 1970-01-01 01:00:00.000000000 +0100 | ||
217 | +++ vzctl-3.0.18-magellan/etc/dists/scripts/magellan-set_hostname.sh 2007-07-22 00:45:13.000000000 +0200 | ||
218 | @@ -0,0 +1,60 @@ | ||
219 | +#!/bin/bash | ||
220 | +# Copyright (C) 2000-2007 SWsoft. All rights reserved. | ||
221 | +# | ||
222 | +# This program is free software; you can redistribute it and/or modify | ||
223 | +# it under the terms of the GNU General Public License as published by | ||
224 | +# the Free Software Foundation; either version 2 of the License, or | ||
225 | +# (at your option) any later version. | ||
226 | +# | ||
227 | +# This program is distributed in the hope that it will be useful, | ||
228 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
229 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
230 | +# GNU General Public License for more details. | ||
231 | +# | ||
232 | +# You should have received a copy of the GNU General Public License | ||
233 | +# along with this program; if not, write to the Free Software | ||
234 | +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
235 | +# | ||
236 | +# | ||
237 | +# This script sets hostname inside VE for Magellan like distros | ||
238 | +# For usage info see vz-veconfig(5) man page. | ||
239 | +# | ||
240 | +# Some parameters are passed in environment variables. | ||
241 | +# Required parameters: | ||
242 | +# Optional parameters: | ||
243 | +# HOSTNM | ||
244 | +# Sets host name for this VE. Modifies /etc/hosts and | ||
245 | +# /etc/sysconfig/network (in RedHat) or /etc/rc.config (in SuSE) | ||
246 | + | ||
247 | +function set_host() | ||
248 | +{ | ||
249 | + local cfgfile="$1" | ||
250 | + local var=$2 | ||
251 | + local val=$3 | ||
252 | + local host= | ||
253 | + | ||
254 | + [ -z "${val}" ] && return 0 | ||
255 | + if grep -q -E "[[:space:]]${val}" ${cfgfile} 2>/dev/null; then | ||
256 | + return; | ||
257 | + fi | ||
258 | + if echo "${val}" | grep "\." >/dev/null 2>&1; then | ||
259 | + host=${val%%.*} | ||
260 | + fi | ||
261 | + host=" ${val} ${host}" | ||
262 | + put_param2 "${cfgfile}" "${var}" "${host} localhost localhost.localdomain" | ||
263 | +} | ||
264 | + | ||
265 | +function set_hostname() | ||
266 | +{ | ||
267 | + local cfgfile=$1 | ||
268 | + local hostname=$2 | ||
269 | + | ||
270 | + [ -z "${hostname}" ] && return 0 | ||
271 | + echo "${hostname}" > ${cfgfile} | ||
272 | + hostname ${hostname} | ||
273 | +} | ||
274 | + | ||
275 | +set_host /etc/hosts "127.0.0.1" "${HOSTNM}" | ||
276 | +set_hostname /etc/hostname "${HOSTNM}" | ||
277 | + | ||
278 | +exit 0 | ||
279 | diff -Naur vzctl-3.0.18/etc/dists/scripts/magellan-set_ugid_quota.sh vzctl-3.0.18-magellan/etc/dists/scripts/magellan-set_ugid_quota.sh | ||
280 | --- vzctl-3.0.18/etc/dists/scripts/magellan-set_ugid_quota.sh 1970-01-01 01:00:00.000000000 +0100 | ||
281 | +++ vzctl-3.0.18-magellan/etc/dists/scripts/magellan-set_ugid_quota.sh 2007-07-22 00:45:17.000000000 +0200 | ||
282 | @@ -0,0 +1,72 @@ | ||
283 | +#!/bin/bash | ||
284 | +# Copyright (C) 2000-2007 SWsoft. All rights reserved. | ||
285 | +# | ||
286 | +# This program is free software; you can redistribute it and/or modify | ||
287 | +# it under the terms of the GNU General Public License as published by | ||
288 | +# the Free Software Foundation; either version 2 of the License, or | ||
289 | +# (at your option) any later version. | ||
290 | +# | ||
291 | +# This program is distributed in the hope that it will be useful, | ||
292 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
293 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
294 | +# GNU General Public License for more details. | ||
295 | +# | ||
296 | +# You should have received a copy of the GNU General Public License | ||
297 | +# along with this program; if not, write to the Free Software | ||
298 | +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
299 | +# | ||
300 | +# | ||
301 | +# This script configures quota startup script inside VE for Magellan like distros | ||
302 | +# | ||
303 | +# Parameters are passed in environment variables. | ||
304 | +# Required parameters: | ||
305 | +# MINOR - root device minor number | ||
306 | +# MAJOR - root device major number | ||
307 | +SCRIPTANAME='/etc/rc.d/init.d/vzquota' | ||
308 | +RCDIRS="/etc/rc.d" | ||
309 | + | ||
310 | +if [ -z "$MAJOR" ]; then | ||
311 | + rm -f ${SCRIPTANAME} > /dev/null 2>&1 | ||
312 | + rm -f /etc/mtab > /dev/null 2>&1 | ||
313 | + ln -sf /proc/mounts /etc/mtab | ||
314 | + exit 0 | ||
315 | +fi | ||
316 | +echo -e '#!/bin/sh | ||
317 | +start() { | ||
318 | + [ -e "/dev/'${DEVFS}'" ] || mknod /dev/'${DEVFS}' b '$MAJOR' '$MINOR' | ||
319 | + rm -f /etc/mtab >/dev/null 2>&1 | ||
320 | + echo "/dev/'${DEVFS}' / reiserfs rw,usrquota,grpquota 0 0" > /etc/mtab | ||
321 | + mnt=`grep -v " / " /proc/mounts` | ||
322 | + if [ $? == 0 ]; then | ||
323 | + echo "$mnt" >> /etc/mtab | ||
324 | + fi | ||
325 | + quotaon -aug | ||
326 | +} | ||
327 | +case "$1" in | ||
328 | + start) | ||
329 | + start | ||
330 | + ;; | ||
331 | + *) | ||
332 | + exit | ||
333 | +esac ' > ${SCRIPTANAME} || { | ||
334 | + echo "Unable to create ${SCRIPTNAME}" | ||
335 | + exit 1 | ||
336 | +} | ||
337 | +chmod 755 ${SCRIPTANAME} | ||
338 | + | ||
339 | +RC= | ||
340 | +for RC in ${RCDIRS}; do | ||
341 | + [ -d ${RC}/rc3.d ] && break | ||
342 | +done | ||
343 | + | ||
344 | +if [ -z "${RC}" ]; then | ||
345 | + echo "Unable to find runlevel directories" | ||
346 | + exit 1 | ||
347 | +fi | ||
348 | + | ||
349 | +for dir in `ls -d ${RC}/rc[0-6].d`; do | ||
350 | + ln -sf ${SCRIPTANAME} ${dir}/S10vzquota | ||
351 | +done | ||
352 | + | ||
353 | +exit 0 | ||
354 | + | ||
355 | diff -Naur vzctl-3.0.18/etc/init.d/Makefile.am vzctl-3.0.18-magellan/etc/init.d/Makefile.am | ||
356 | --- vzctl-3.0.18/etc/init.d/Makefile.am 2007-07-06 09:46:25.000000000 +0200 | ||
357 | +++ vzctl-3.0.18-magellan/etc/init.d/Makefile.am 2007-07-21 17:29:07.000000000 +0200 | ||
358 | @@ -15,7 +15,7 @@ | ||
359 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
360 | # | ||
361 | |||
362 | -INITSCRIPTS = vz-redhat vz-gentoo | ||
363 | +INITSCRIPTS = vz-redhat vz-gentoo vz-magellan | ||
364 | |||
365 | EXTRA_DIST = $(INITSCRIPTS:%=%.in) | ||
366 | |||
367 | @@ -34,3 +34,7 @@ | ||
368 | install-gentoo: vz-gentoo | ||
369 | $(mkinstalldirs) $(DESTDIR)$(initddir) | ||
370 | $(INSTALL_SCRIPT) vz-gentoo $(DESTDIR)$(initddir)/vz | ||
371 | + | ||
372 | +install-gentoo: vz-magellan | ||
373 | + $(mkinstalldirs) $(DESTDIR)$(initddir) | ||
374 | + $(INSTALL_SCRIPT) vz-magellan $(DESTDIR)$(initddir)/vz | ||
375 | diff -Naur vzctl-3.0.18/etc/init.d/Makefile.in vzctl-3.0.18-magellan/etc/init.d/Makefile.in | ||
376 | --- vzctl-3.0.18/etc/init.d/Makefile.in 2007-07-06 09:46:34.000000000 +0200 | ||
377 | +++ vzctl-3.0.18-magellan/etc/init.d/Makefile.in 2007-07-21 17:28:37.000000000 +0200 | ||
378 | @@ -204,7 +204,7 @@ | ||
379 | target_cpu = @target_cpu@ | ||
380 | target_os = @target_os@ | ||
381 | target_vendor = @target_vendor@ | ||
382 | -INITSCRIPTS = vz-redhat vz-gentoo | ||
383 | +INITSCRIPTS = vz-redhat vz-gentoo vz-magellan | ||
384 | EXTRA_DIST = $(INITSCRIPTS:%=%.in) | ||
385 | CLEANFILES = $(INITSCRIPTS) | ||
386 | @ENABLE_BASHCOMP_TRUE@bashcdir = $(sysconfdir)/bash_completion.d | ||
387 | @@ -407,6 +407,11 @@ | ||
388 | install-gentoo: vz-gentoo | ||
389 | $(mkinstalldirs) $(DESTDIR)$(initddir) | ||
390 | $(INSTALL_SCRIPT) vz-gentoo $(DESTDIR)$(initddir)/vz | ||
391 | + | ||
392 | +install-magellan: vz-magellan | ||
393 | + $(mkinstalldirs) $(DESTDIR)$(initddir) | ||
394 | + $(INSTALL_SCRIPT) vz-magellan $(DESTDIR)$(initddir)/vz | ||
395 | + | ||
396 | # Tell versions [3.59,3.63) of GNU make to not export all variables. | ||
397 | # Otherwise a system limit (for SysV at least) may be exceeded. | ||
398 | .NOEXPORT: | ||
399 | diff -Naur vzctl-3.0.18/etc/init.d/vz-magellan.in vzctl-3.0.18-magellan/etc/init.d/vz-magellan.in | ||
400 | --- vzctl-3.0.18/etc/init.d/vz-magellan.in 1970-01-01 01:00:00.000000000 +0100 | ||
401 | +++ vzctl-3.0.18-magellan/etc/init.d/vz-magellan.in 2007-07-22 00:44:28.000000000 +0200 | ||
402 | @@ -0,0 +1,405 @@ | ||
403 | +#!/bin/bash | ||
404 | niro | 274 | +# $Header: /root/magellan-cvs/src/vzctl/patches/vzctl-3.0.18-magellan.patch,v 1.2 2007-07-21 22:55:33 niro Exp $ |
405 | niro | 273 | + |
406 | +#%rlevels: 3:s 4:s 5:s 0:k 1:k 2:k 6:k | ||
407 | +#%start: 96 | ||
408 | +#%stop: 88 | ||
409 | + | ||
410 | +#deps | ||
411 | +#%needs: | ||
412 | +#%before: | ||
413 | +#%after: | ||
414 | + | ||
415 | +source /etc/sysconfig/rc | ||
416 | +source $rc_functions | ||
417 | + | ||
418 | +check_config() | ||
419 | +{ | ||
420 | + source /etc/vz/vz.conf | ||
421 | + | ||
422 | + # if we don't want openvz running, say so | ||
423 | + [ "${VIRTUOZZO}" = "yes" ] || return 1 | ||
424 | + | ||
425 | + # set default values | ||
426 | + : ${VZCTL:=@SBINDIR@/vzctl} | ||
427 | + : ${VZQUOTA:=@SBINDIR@/vzquota} | ||
428 | + : ${VZVEINFO:=/proc/vz/veinfo} | ||
429 | + : ${VESTAT:=/proc/vz/vestat} | ||
430 | + : ${VPSCONFDIR:=@VPSCONFDIR@} | ||
431 | + : ${VZDEV:=venet0} | ||
432 | + : ${SRC_CRONSCRIPT_DIR:=@CRONDDIR@} | ||
433 | + : ${DST_CRONSCRIPT_DIR:=@DST_CRONDDIR@} | ||
434 | + | ||
435 | + if [ "${MODULES_DISABLED}" != "yes" ] | ||
436 | + then | ||
437 | + : ${PRELOAD_MODULES:="af_packet"} | ||
438 | + : ${MODULES:="vzmon vzdquota vzdev"} | ||
439 | + : ${MIGRATE_MODULES:="vzcpt vzrst"} | ||
440 | + : ${NET_MODULES="vznetdev vznet"} | ||
441 | + | ||
442 | + # check if you should load vzwdog module | ||
443 | + [ "${VZWDOG}" = "yes" ] && MODULES="${MODULES} vzwdog" | ||
444 | + fi | ||
445 | + | ||
446 | + # we need a working vzctl | ||
447 | + if [ ! -x "${VZCTL}" ] | ||
448 | + then | ||
449 | + ${FAILURE} "vzctl missing (${VZCTL})" | ||
450 | + return 1 | ||
451 | + fi | ||
452 | + | ||
453 | + if [ -z "${VE0CPUUNITS}" ] | ||
454 | + then | ||
455 | + ${WARNING} "VE0CPUUNITS is not set in /etc/conf.d/vz; using default value of 1000" | ||
456 | + VE0CPUUNITS=1000 | ||
457 | + fi | ||
458 | + return 0 | ||
459 | +} | ||
460 | + | ||
461 | +# We used to install OpenVZ cron job when the vzctl package was | ||
462 | +# installed, irrespective of whether OpenVZ was actually being | ||
463 | +# run. Although the cron jobs didn't create any problems if someone | ||
464 | +# wasn't running OpenVZ some users complained about the cron log file | ||
465 | +# filling up, resource usage, and power consumption since systems | ||
466 | +# wouldn't really idle. It really only makes sense to run the OpenVZ | ||
467 | +# cron job if the vz service is turned on and not just merely | ||
468 | +# having the package installed. This init.d script is an obvious place | ||
469 | +# to install or remove the cron jobs based on the service | ||
470 | +# being enabled or not. | ||
471 | +setup_cron() | ||
472 | +{ | ||
473 | + [ -z "${SRC_CRONSCRIPT_DIR}" ] && return | ||
474 | + [ -d "${SRC_CRONSCRIPT_DIR}" ] || return | ||
475 | + install -m644 -o root -g root ${SRC_CRONSCRIPT_DIR}/vz ${DST_CRONSCRIPT_DIR} | ||
476 | +} | ||
477 | + | ||
478 | +remove_cron() | ||
479 | +{ | ||
480 | + [ -z "${SRC_CRONSCRIPT_DIR}" ] && return | ||
481 | + [ -d "${SRC_CRONSCRIPT_DIR}" ] || return | ||
482 | + cat > ${DST_CRONSCRIPT_DIR}/vz <<EOF | ||
483 | +# DO NOT EDIT THIS FILE! | ||
484 | +# | ||
485 | +# Contents of this file managed by /etc/init.d/vz script | ||
486 | +# Master copy is ${SRC_CRONSCRIPT_DIR}/vz. | ||
487 | +# Consult that file for documentation. | ||
488 | +EOF | ||
489 | +} | ||
490 | + | ||
491 | +setup_ve0() | ||
492 | +{ | ||
493 | + local msg retval ve0conf="${VPSCONFDIR}/0.conf" | ||
494 | + | ||
495 | + msg=$(${VZCTL} set 0 --cpuunits ${VE0CPUUNITS} 2>&1) | ||
496 | + [ $? -ne 0 ] && ${WARNING} "vzctl set 0 --cpuunits ${VE0CPUUNITS} failed: ${msg}" | ||
497 | + | ||
498 | + test -f ${ve0conf} || return | ||
499 | + egrep -q '^ONBOOT=yes\|^ONBOOT=\"yes\"' ${ve0conf} || return | ||
500 | + | ||
501 | + echo -en ${COLOREDSTAR}"Configuring hardware node UB resources: " | ||
502 | + msg=$(${VZCTL} set 0 --reset_ub 2>&1) | ||
503 | + retval=$? | ||
504 | + echo "${msg}" | ||
505 | + evaluate_retval ${retval} | ||
506 | +} | ||
507 | + | ||
508 | +start_net() | ||
509 | +{ | ||
510 | + local mod | ||
511 | + | ||
512 | + # we don't operate on a running interface | ||
513 | + if /sbin/ip addr list | grep -q "venet0:.*UP" 2>/dev/null | ||
514 | + then | ||
515 | + return 0 | ||
516 | + fi | ||
517 | + | ||
518 | + # load necessary modules | ||
519 | + for mod in ${NET_MODULES} | ||
520 | + do | ||
521 | + /sbin/modprobe ${mod} 2>/dev/null | ||
522 | + done | ||
523 | + | ||
524 | + if [ ! -f ${VZVEINFO} ] | ||
525 | + then | ||
526 | + return 0 | ||
527 | + fi | ||
528 | + | ||
529 | + # configure the device | ||
530 | + echo -e ${COLOREDSTAR}"Bringing up interface ${VZDEV}" | ||
531 | + /sbin/ip link set ${VZDEV} up | ||
532 | + evaluate_retval | ||
533 | + | ||
534 | + /sbin/ip addr add 0.0.0.0/0 dev ${VZDEV} | ||
535 | + | ||
536 | + echo -e ${COLOREDSTAR}"Configuring interface ${VZDEV}" | ||
537 | + /sbin/sysctl -q -w net.ipv4.conf.${VZDEV}.send_redirects=0 | ||
538 | + evaluate_retval | ||
539 | +} | ||
540 | + | ||
541 | +stop_net() | ||
542 | +{ | ||
543 | + local mod | ||
544 | + | ||
545 | + if /sbin/ip addr list | grep -q "venet0:.*UP" 2>/dev/null | ||
546 | + then | ||
547 | + echo -e ${COLOREDSTAR}"Bringing down interface ${VZDEV}" | ||
548 | + /sbin/ip link set ${VZDEV} down 2>/dev/null | ||
549 | + evaluate_retval | ||
550 | + fi | ||
551 | + | ||
552 | + # remove all modules we probably loaded on start_net | ||
553 | + for mod in ${NET_MODULES} | ||
554 | + do | ||
555 | + /sbin/modprobe -r ${mod} > /dev/null 2>&1 | ||
556 | + done | ||
557 | +} | ||
558 | + | ||
559 | +start_ve() | ||
560 | +{ | ||
561 | + local veid velist msg need_restart="" retval | ||
562 | + | ||
563 | + # get all VEs we should start on boot | ||
564 | + if ! cd ${VPSCONFDIR} | ||
565 | + then | ||
566 | + ${FAILURE} "Unable to cd to ${VPSCONFDIR}" | ||
567 | + return 1 | ||
568 | + fi | ||
569 | + velist=$(grep -l '^ONBOOT=yes\|^ONBOOT=\"yes\"' [0-9]*.conf 2>/dev/null | sed -e 's/.conf//g' | sort -n) | ||
570 | + cd - >/dev/null | ||
571 | + | ||
572 | + /sbin/sysctl -q -w net.ipv4.route.src_check=0 | ||
573 | + | ||
574 | + for veid in ${velist} | ||
575 | + do | ||
576 | + echo -en ${COLOREDSTAR}"Starting VE ${veid}" | ||
577 | + if [ "${VZFASTBOOT}" = "yes" -a "${DISK_QUOTA}" = "yes" ] | ||
578 | + then | ||
579 | + ${VZQUOTA} stat ${veid} >/dev/null 2>&1 | ||
580 | + if [ $? -eq 6 ] | ||
581 | + then | ||
582 | + if ${VZQUOTA} show ${veid} 2>&1 | grep "vzquota : (warning) Quota is running" >/dev/null 2>&1 | ||
583 | + then | ||
584 | + ${VZQUOTA} on ${veid} --nocheck >/dev/null 2>&1 | ||
585 | + need_restart="${need_restart} ${veid}" | ||
586 | + fi | ||
587 | + fi | ||
588 | + fi | ||
589 | + msg=$(${VZCTL} start ${veid} 2>&1) | ||
590 | + retval=$? | ||
591 | + echo "${mesg}" | ||
592 | + evaluate_retval ${retval} | ||
593 | + done | ||
594 | + | ||
595 | + for veid in ${need_restart} | ||
596 | + do | ||
597 | + echo -en ${COLOREDSTAR}"Stopping VE ${veid}" | ||
598 | + msg=$(${VZCTL} stop ${veid}) | ||
599 | + retval=$? | ||
600 | + echo "${mesg}" | ||
601 | + evaluate_retval ${retval} | ||
602 | + | ||
603 | + echo -e ${COLOREDSTAR}"Starting VE ${veid}" | ||
604 | + msg=$($VZCTL start ${veid} 2>&1) | ||
605 | + retval=$? | ||
606 | + echo "${mesg}" | ||
607 | + evaluate_retval ${retval} | ||
608 | + done | ||
609 | + | ||
610 | + # we're ok even if some VEs failed to start | ||
611 | + return 0 | ||
612 | +} | ||
613 | + | ||
614 | +get_parallel() | ||
615 | +{ | ||
616 | + [ -n "${PARALLEL}" ] && return | ||
617 | + PARALLEL=`awk ' | ||
618 | +BEGIN { num=0; } | ||
619 | +$1 == "processor" { num++; } | ||
620 | +END { print num * 4; }' /proc/cpuinfo` | ||
621 | +} | ||
622 | + | ||
623 | +stop_ve() | ||
624 | +{ | ||
625 | + local veid velist msg m mounts fail i iter pid pids quota retval | ||
626 | + | ||
627 | + if [ -f ${VESTAT} ] | ||
628 | + then | ||
629 | + get_parallel | ||
630 | + for ((i = 0; i <= 2; i++)) | ||
631 | + do | ||
632 | + iter=0 | ||
633 | + pids= | ||
634 | + velist=$(awk '$1 != "VEID" && $1 != "Version:" {print $1}' ${VESTAT}) | ||
635 | + for veid in ${velist} | ||
636 | + do | ||
637 | + echo -e ${COLOREDSTAR}"Shutting down VE $veid" | ||
638 | + # Set fairsched parameters to maximum so | ||
639 | + # VE will stop fast | ||
640 | + ${VZCTL} set ${veid} --cpuunits 2000 --cpulimit 0 >/dev/null 2>&1 | ||
641 | + ${VZCTL} --skiplock stop ${veid} >/dev/null 2>&1 & | ||
642 | + pids="${pids} $!" | ||
643 | + let iter++ | ||
644 | + if [ ${iter} -gt ${PARALLEL} ] | ||
645 | + then | ||
646 | + for pid in ${pids} | ||
647 | + do | ||
648 | + wait ${pid} | ||
649 | + done | ||
650 | + pids= | ||
651 | + iter=0 | ||
652 | + fi | ||
653 | + done | ||
654 | + | ||
655 | + for pid in ${pids} | ||
656 | + do | ||
657 | + wait ${pid} | ||
658 | + done | ||
659 | + done | ||
660 | + fi | ||
661 | + | ||
662 | + iter=0 | ||
663 | + fail=1 | ||
664 | + | ||
665 | + while [ ${iter} -lt 5 -a ${fail} -ne 0 ] | ||
666 | + do | ||
667 | + fail=0 | ||
668 | + mounts=$(awk '{if ($3=="simfs") print $2}' /proc/mounts) | ||
669 | + | ||
670 | + for m in ${mounts} | ||
671 | + do | ||
672 | + echo -en ${COLOREDSTAR}"Unmounting VE area ${m}" | ||
673 | + msg=$(umount ${m} 2>&1) | ||
674 | + retval=$? | ||
675 | + echo "${mesg}" | ||
676 | + evaluate_retval ${retval} | ||
677 | + if [ $? -ne 0 ] | ||
678 | + then | ||
679 | + let fail++ | ||
680 | + fuser -k -m ${m} > /dev/null 2>&1 | ||
681 | + fi | ||
682 | + done | ||
683 | + | ||
684 | + let iter++ | ||
685 | + done | ||
686 | + | ||
687 | + # turn quota off | ||
688 | + quota=$(awk -F: '/^[0-9]+:/{print $1}' /proc/vz/vzquota 2>/dev/null) | ||
689 | + | ||
690 | + for m in ${quota} | ||
691 | + do | ||
692 | + echo -e ${COLOREDSTAR}"Turning quota off for VE ${m}" | ||
693 | + msg=$(vzquota off ${m} 2>&1) | ||
694 | + retval=$? | ||
695 | + echo "${mesg}" | ||
696 | + evaluate_retval ${retval} | ||
697 | + done | ||
698 | +} | ||
699 | + | ||
700 | +status_ve() | ||
701 | +{ | ||
702 | + local velist veid | ||
703 | + | ||
704 | + check_config | ||
705 | + | ||
706 | + if [ -f ${VESTAT} ] | ||
707 | + then | ||
708 | + velist=$(awk '$1 != "VEID" && $1 != "Version:" {print $1}' ${VESTAT}) | ||
709 | + for veid in ${velist} | ||
710 | + do | ||
711 | + ${VZCTL} status ${veid} | ||
712 | + done | ||
713 | + fi | ||
714 | +} | ||
715 | + | ||
716 | +case "$1" in | ||
717 | + start) | ||
718 | + check_config || exit | ||
719 | + | ||
720 | + echo -e ${COLOREDSTAR}"Loading OpenVZ modules" | ||
721 | + for mod in ${PRELOAD_MODULES} | ||
722 | + do | ||
723 | + /sbin/modprobe -r ${mod} >/dev/null 2>&1 | ||
724 | + /sbin/modprobe ${mod} >/dev/null 2>&1 | ||
725 | + done | ||
726 | + | ||
727 | + for mod in ${MODULES} | ||
728 | + do | ||
729 | + /sbin/modprobe ${mod} >/dev/null 2>&1 | ||
730 | + retval=$? | ||
731 | + if [ ${retval} -ne 0 ] | ||
732 | + then | ||
733 | + ${FAILURE} "failed to load module ${mod}" | ||
734 | + exit ${retval} | ||
735 | + fi | ||
736 | + done | ||
737 | + | ||
738 | + for mod in ${MIGRATE_MODULES} | ||
739 | + do | ||
740 | + /sbin/modprobe ${mod} >/dev/null 2>&1 | ||
741 | + done | ||
742 | + evaluate_retval | ||
743 | + | ||
744 | + if [ ! -e /dev/vzctl ] | ||
745 | + then | ||
746 | + ${FAILURE} "Missing device node /dev/vzctl" | ||
747 | + echo | ||
748 | + echo "Please create the vzctl device node using the following command:" | ||
749 | + echo " /bin/mknod /dev/vzctl c 126 0" | ||
750 | + echo | ||
751 | + exit 1 | ||
752 | + fi | ||
753 | + | ||
754 | + start_net | ||
755 | + setup_ve0 | ||
756 | + setup_cron | ||
757 | + start_ve | ||
758 | + | ||
759 | + update_svcstatus $1 | ||
760 | + splash svc_started "$(basename $0)" 0 | ||
761 | + ;; | ||
762 | + | ||
763 | + stop) | ||
764 | + check_config || exit | ||
765 | + | ||
766 | + stop_ve | ||
767 | + remove_cron | ||
768 | + stop_net | ||
769 | + | ||
770 | + echo -e ${COLOREDSTAR}"Unloading OpenVZ modules" | ||
771 | + for mod in ${MIGRATE_MODULES} | ||
772 | + do | ||
773 | + /sbin/modprobe -r ${mod} > /dev/null 2>&1 | ||
774 | + done | ||
775 | + | ||
776 | + for mod in ${MODULES} | ||
777 | + do | ||
778 | + /sbin/modprobe -r ${mod} > /dev/null 2>&1 | ||
779 | + done | ||
780 | + | ||
781 | + for mod in ${PRELOAD_MODULES} | ||
782 | + do | ||
783 | + /sbin/modprobe -r ${mod} > /dev/null 2>&1 | ||
784 | + done | ||
785 | + # Even if some modules failed to unload (say they were not loaded) | ||
786 | + # we return success for the service to be marked as stopped. | ||
787 | + print_status success | ||
788 | + | ||
789 | + update_svcstatus $1 | ||
790 | + splash svc_stopped "$(basename $0)" 0 | ||
791 | + ;; | ||
792 | + | ||
793 | + restart) | ||
794 | + $0 stop | ||
795 | + sleep 1 | ||
796 | + $0 start | ||
797 | + ;; | ||
798 | + | ||
799 | + status) | ||
800 | + status_ve | ||
801 | + ;; | ||
802 | + | ||
803 | + *) | ||
804 | + echo "Usage: $0 {start|stop|restart|status}" | ||
805 | + exit 1 | ||
806 | + ;; | ||
807 | +esac | ||
808 | niro | 274 | diff -Naur vzctl-3.0.18/Makefile.am vzctl-3.0.18-magellan/Makefile.am |
809 | --- vzctl-3.0.18/Makefile.am 2007-07-06 09:46:25.000000000 +0200 | ||
810 | +++ vzctl-3.0.18-magellan/Makefile.am 2007-07-22 00:54:26.000000000 +0200 | ||
811 | @@ -44,6 +44,7 @@ | ||
812 | DISTRO_TARGETS = \ | ||
813 | install-redhat \ | ||
814 | install-gentoo \ | ||
815 | + install-magellan \ | ||
816 | install-suse \ | ||
817 | install-debian | ||
818 | |||
819 | diff -Naur vzctl-3.0.18/Makefile.in vzctl-3.0.18-magellan/Makefile.in | ||
820 | --- vzctl-3.0.18/Makefile.in 2007-07-06 09:46:36.000000000 +0200 | ||
821 | +++ vzctl-3.0.18-magellan/Makefile.in 2007-07-22 00:54:41.000000000 +0200 | ||
822 | @@ -214,6 +214,7 @@ | ||
823 | DISTRO_TARGETS = \ | ||
824 | install-redhat \ | ||
825 | install-gentoo \ | ||
826 | + install-magellan \ | ||
827 | install-suse \ | ||
828 | install-debian | ||
829 |