1 |
pva 08/10/13 09:25:59 |
2 |
|
3 |
Added: vzctl-3.0.22-scripts-openrc.patch |
4 |
Log: |
5 |
Made scripts openvz compatible. Skipped revisions to have possibility to put major updates (e.g. security) without this changes applied. |
6 |
(Portage version: 2.2_rc11/cvs/Linux 2.6.26-gentoo-r1 i686) |
7 |
|
8 |
Revision Changes Path |
9 |
1.1 sys-cluster/vzctl/files/vzctl-3.0.22-scripts-openrc.patch |
10 |
|
11 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-cluster/vzctl/files/vzctl-3.0.22-scripts-openrc.patch?rev=1.1&view=markup |
12 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-cluster/vzctl/files/vzctl-3.0.22-scripts-openrc.patch?rev=1.1&content-type=text/plain |
13 |
|
14 |
Index: vzctl-3.0.22-scripts-openrc.patch |
15 |
=================================================================== |
16 |
--- etc/dists/scripts/gentoo-add_ip.sh 2008-09-16 14:25:00 +0000 |
17 |
+++ etc/dists/scripts/gentoo-add_ip.sh 2008-08-28 20:55:10 +0000 |
18 |
@@ -16,7 +16,8 @@ |
19 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
20 |
# |
21 |
# |
22 |
-# This script configure IP alias(es) inside Gentoo like VE. |
23 |
+# This script configures IP alias(es) inside Gentoo based VE with |
24 |
+# baselayout-1/openrc used as services/stratup/shutdown system. |
25 |
# |
26 |
# Parameters are passed in environment variables. |
27 |
# Required parameters: |
28 |
@@ -29,40 +30,62 @@ |
29 |
# |
30 |
VENET_DEV=venet0 |
31 |
|
32 |
- |
33 |
-IFCFG_DIR=/etc/conf.d |
34 |
-IFCFG=${IFCFG_DIR}/net |
35 |
+#IFCFG_DIR=/etc/conf.d |
36 |
+IFCFG=/etc/conf.d/net |
37 |
|
38 |
SCRIPT=/etc/runlevels/default/net.${VENET_DEV} |
39 |
|
40 |
HOSTFILE=/etc/hosts |
41 |
|
42 |
-function fix_net() |
43 |
+# Return true is we have openrc based VE and false if not. |
44 |
+# Note: /etc/gentoo-release has nothing to do with openrc |
45 |
+function is_openrc() |
46 |
+{ |
47 |
+ [ -f /lib/librc.so ] |
48 |
+} |
49 |
+ |
50 |
+function comment_line_regex() |
51 |
+{ |
52 |
+ cp -pf ${IFCFG} ${IFCFG}.$$ || \ |
53 |
+ error "Failed to comment ${1}: unable to copy ${IFCFG}" ${VZ_FS_NO_DISK_SPACE} |
54 |
+ sed -e "s/${1}/#${1}/" < ${IFCFG} > ${IFCFG}.$$ && \ |
55 |
+ mv -f ${IFCFG}.$$ ${IFCFG} 2>/dev/null |
56 |
+ if [ $? -ne 0 ]; then |
57 |
+ rm -f ${IFCFG}.$$ 2>/dev/null |
58 |
+ error "Failed to comment ${1}: unable to create ${IFCFG}." |
59 |
+ fi |
60 |
+} |
61 |
+ |
62 |
+function set_config() |
63 |
+{ |
64 |
+ if ! grep -qe "^config_eth" ${IFCFG} 2>/dev/null; then |
65 |
+ comment_line_regex "^config_eth" |
66 |
+ comment_line_regex "^routes_eth" |
67 |
+ fi |
68 |
+ if is_openrc ; then |
69 |
+ put_param ${IFCFG} "config_${VENET_DEV}" "" |
70 |
+ put_param ${IFCFG} "routes_${VENET_DEV}" "default" |
71 |
+ else |
72 |
+ put_param3 ${IFCFG} "config_${VENET_DEV}" "" |
73 |
+ put_param3 ${IFCFG} "routes_${VENET_DEV}" \ |
74 |
+ "-net ${FAKEGATEWAYNET}/24" # dev ${VENET_DEV} |
75 |
+ add_param3 ${IFCFG} "routes_${VENET_DEV}" "default via ${FAKEGATEWAY}" |
76 |
+ fi |
77 |
+} |
78 |
+ |
79 |
+function set_rc() |
80 |
{ |
81 |
[ -f "${SCRIPT}" ] && return 0 |
82 |
rc-update del net.eth0 &>/dev/null |
83 |
+ rc-update add net.lo boot &>/dev/null |
84 |
ln -sf /etc/init.d/net.lo /etc/init.d/net.${VENET_DEV} |
85 |
- rc-update add net.lo boot &>/dev/null |
86 |
rc-update add net.${VENET_DEV} default &>/dev/null |
87 |
- if ! grep -qe "^config_eth" ${IFCFG} 2>/dev/null; then |
88 |
- return 0 |
89 |
- fi |
90 |
- cp -pf ${IFCFG} ${IFCFG}.$$ || error "Unable to copy ${IFCFG}" |
91 |
- sed -e 's/^config_eth/#config_eth/' -e 's/^routes_eth/#routes_eth/' < ${IFCFG} > ${IFCFG}.$$ && mv -f ${IFCFG}.$$ ${IFCFG} 2>/dev/null |
92 |
- if [ $? -ne 0 ]; then |
93 |
- rm -f ${IFCFG}.$$ 2>/dev/null |
94 |
- error "Unable to create ${IFCFG}" |
95 |
- fi |
96 |
} |
97 |
|
98 |
-function setup_network() |
99 |
+function init_netconfig() |
100 |
{ |
101 |
- fix_net |
102 |
- put_param3 ${IFCFG} "config_${VENET_DEV}" "" |
103 |
- # add fake route |
104 |
- put_param3 ${IFCFG} "routes_${VENET_DEV}" \ |
105 |
- "-net ${FAKEGATEWAYNET}/24" # dev ${VENET_DEV} |
106 |
- add_param3 ${IFCFG} "routes_${VENET_DEV}" "default via ${FAKEGATEWAY}" |
107 |
+ set_rc |
108 |
+ set_config |
109 |
# Set up /etc/hosts |
110 |
if [ ! -f ${HOSTFILE} ]; then |
111 |
echo "127.0.0.1 localhost.localdomain localhost" > $HOSTFILE |
112 |
@@ -72,25 +95,27 @@ |
113 |
function add_ip() |
114 |
{ |
115 |
local ip |
116 |
- local new_ips |
117 |
- |
118 |
- # In case we are starting VE |
119 |
- if [ "x${VE_STATE}" = "xstarting" ]; then |
120 |
- setup_network |
121 |
- fi |
122 |
- |
123 |
- if [ "x${IPDELALL}" = "xyes" ]; then |
124 |
- put_param3 "${IFCFG}" "config_${VENET_DEV}" "" |
125 |
+ if [ "x${VE_STATE}" = "xstarting" -o "x${IPDELALL}" = "xyes" ]; then |
126 |
+ init_netconfig |
127 |
+ if [ "x${IPDELALL}" = "xyes" ]; then |
128 |
+ /etc/init.d/net.${VENET_DEV} stop >/dev/null 2>&1 |
129 |
+ return 0 |
130 |
+ fi |
131 |
fi |
132 |
|
133 |
for ip in ${IP_ADDR}; do |
134 |
- grep -qw "^config_${VENET_DEV}=\(.*\"${ip}[\"\/].*\)" ${IFCFG} || |
135 |
- add_param3 "${IFCFG}" "config_${VENET_DEV}" "${ip}/32" |
136 |
+ if ! grep -qw "config_${VENET_DEV}=\(.*\"${ip}[\"\/].*\)" ${IFCFG}; then |
137 |
+ if is_openrc ; then |
138 |
+ add_param "${IFCFG}" "config_${VENET_DEV}" "${ip}/32" |
139 |
+ else |
140 |
+ add_param3 "${IFCFG}" "config_${VENET_DEV}" "${ip}/32" |
141 |
+ fi |
142 |
+ fi |
143 |
done |
144 |
|
145 |
if [ "x${VE_STATE}" = "xrunning" ]; then |
146 |
# synchronyze config files & interfaces |
147 |
- /etc/init.d/net.${VENET_DEV} restart |
148 |
+ /etc/init.d/net.${VENET_DEV} restart >/dev/null 2>&1 |
149 |
fi |
150 |
} |
151 |
|
152 |
|
153 |
--- etc/dists/scripts/gentoo-del_ip.sh 2008-09-16 14:25:00 +0000 |
154 |
+++ etc/dists/scripts/gentoo-del_ip.sh 2008-08-28 20:55:33 +0000 |
155 |
@@ -28,19 +28,28 @@ |
156 |
VENET_DEV=venet0 |
157 |
CFGFILE=/etc/conf.d/net |
158 |
|
159 |
-# Function to delete IP address for Debian template |
160 |
+# Return true is we have openrc based VE and false if not. |
161 |
+# Note: /etc/gentoo-release has nothing to do with openrc |
162 |
+function is_openrc() |
163 |
+{ |
164 |
+ [ -f /lib/librc.so ] |
165 |
+} |
166 |
+ |
167 |
function del_ip() |
168 |
{ |
169 |
- local found= |
170 |
- local ip e_ip |
171 |
- |
172 |
+ local ip |
173 |
for ip in ${IP_ADDR}; do |
174 |
- grep -qw "${ip}" ${CFGFILE} && found=true && |
175 |
- del_param3 "${CFGFILE}" "config_${VENET_DEV}" "${ip}/32" |
176 |
+ if grep -qw "${ip}" ${CFGFILE}; then |
177 |
+ if is_openrc ; then |
178 |
+ del_param "${CFGFILE}" "config_${VENET_DEV}" "${ip}/32" |
179 |
+ else |
180 |
+ del_param3 "${CFGFILE}" "config_${VENET_DEV}" "${ip}/32" |
181 |
+ fi |
182 |
+ if [ "x${VE_STATE}" = "xrunning" ]; then |
183 |
+ /etc/init.d/net.${VENET_DEV} restart >/dev/null 2>&1 |
184 |
+ fi |
185 |
+ fi |
186 |
done |
187 |
- if [ -n "${found}" ]; then |
188 |
- /etc/init.d/net.${VENET_DEV} restart 2>/dev/null 1>/dev/null |
189 |
- fi |
190 |
} |
191 |
|
192 |
del_ip |
193 |
|
194 |
--- etc/dists/scripts/gentoo-set_hostname.sh 2008-09-16 14:25:00 +0000 |
195 |
+++ etc/dists/scripts/gentoo-set_hostname.sh 2008-08-24 07:47:46 +0000 |
196 |
@@ -16,22 +16,39 @@ |
197 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
198 |
# |
199 |
# |
200 |
-# This script sets hostname inside VE for Gentoo like distros |
201 |
-# For usage info see vz-veconfig(5) man page. |
202 |
+# This script sets hostname inside Gentoo based VE with |
203 |
+# baselayout-1/openrc used as services/stratup/shutdown system. |
204 |
# |
205 |
# Some parameters are passed in environment variables. |
206 |
# Required parameters: |
207 |
# Optional parameters: |
208 |
# HOSTNM |
209 |
-# Sets host name for this VE. Modifies /etc/hosts and |
210 |
-# /etc/sysconfig/network (in RedHat) or /etc/rc.config (in SuSE) |
211 |
+# Sets host name for this VE. Modifies /etc/conf.d/hostname |
212 |
+ |
213 |
+# Return true is we have openrc based VE and false if not. |
214 |
+# Note: /etc/gentoo-release has nothing to do with openrc |
215 |
+function is_openrc() |
216 |
+{ |
217 |
+ [ -f /lib/librc.so ] |
218 |
+} |
219 |
+ |
220 |
function set_hostname() |
221 |
{ |
222 |
local cfgfile=$1 |
223 |
local hostname=$2 |
224 |
|
225 |
[ -z "${hostname}" ] && return 0 |
226 |
- put_param "${cfgfile}" "HOSTNAME" "${hostname}" |
227 |
+ if is_openrc ; then |
228 |
+ if grep -qe "^HOSTNAME=" ${cfgfile} >/dev/null 2>&1; then |
229 |
+ del_param ${cfgfile} "HOSTNAME" |
230 |
+ fi |
231 |
+ put_param "${cfgfile}" "hostname" "${hostname}" |
232 |
+ else |
233 |
+ if grep -qe "^hostname=" ${cfgfile} >/dev/null 2>&1; then |
234 |
+ del_param ${cfgfile} "hostname" |
235 |
+ fi |
236 |
+ put_param "${cfgfile}" "HOSTNAME" "${hostname}" |
237 |
+ fi |
238 |
hostname ${hostname} |
239 |
} |
240 |
|
241 |
|
242 |
--- etc/dists/scripts/gentoo-set_ugid_quota.sh 2008-09-16 14:25:00 +0000 |
243 |
+++ etc/dists/scripts/gentoo-set_ugid_quota.sh 2008-08-28 21:40:00 +0000 |
244 |
@@ -57,6 +57,6 @@ |
245 |
} |
246 |
chmod 755 ${SCRIPTANAME} |
247 |
|
248 |
-ln -sf ${SCRIPTANAME} ${DEFAULT} |
249 |
+rc-update add vzquota default |
250 |
|
251 |
exit 0 |