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