New patch 0008-libvirt-guests-remove-bashisms.patch
Laurent LĂ©onard
13 years ago
0 | From: =?UTF-8?q?Laurent=20L=C3=A9onard?= <laurent@open-minds.org> | |
1 | Date: Thu, 9 Dec 2010 22:36:29 +0100 | |
2 | Subject: [PATCH] Debianize libvirt-guests | |
3 | ||
4 | Origin: vendor | |
5 | --- | |
6 | tools/libvirt-guests.init.in | 79 +++++++++++++++++------------------------- | |
7 | tools/libvirt-guests.sysconf | 6 ++-- | |
8 | 2 files changed, 35 insertions(+), 50 deletions(-) | |
9 | ||
10 | diff --git a/tools/libvirt-guests.init.in b/tools/libvirt-guests.init.in | |
11 | index e28938d..0fe82fb 100644 | |
12 | --- a/tools/libvirt-guests.init.in | |
13 | +++ b/tools/libvirt-guests.init.in | |
14 | @@ -4,8 +4,8 @@ | |
15 | # | |
16 | ### BEGIN INIT INFO | |
17 | # Provides: libvirt-guests | |
18 | -# Required-Start: libvirtd | |
19 | -# Required-Stop: libvirtd | |
20 | +# Required-Start: $remote_fs libvirt-bin | |
21 | +# Required-Stop: $remote_fs libvirt-bin | |
22 | # Default-Start: 2 3 4 5 | |
23 | # Default-Stop: 0 1 6 | |
24 | # Short-Description: suspend/resume libvirt guests on shutdown/boot | |
25 | @@ -14,33 +14,19 @@ | |
26 | # See http://libvirt.org | |
27 | ### END INIT INFO | |
28 | ||
29 | -# the following is chkconfig init header | |
30 | -# | |
31 | -# libvirt-guests: suspend/resume libvirt guests on shutdown/boot | |
32 | -# | |
33 | -# chkconfig: 345 99 01 | |
34 | -# description: This is a script for suspending active libvirt guests \ | |
35 | -# on shutdown and resuming them on next boot \ | |
36 | -# See http://libvirt.org | |
37 | -# | |
38 | - | |
39 | -sysconfdir=@sysconfdir@ | |
40 | -localstatedir=@localstatedir@ | |
41 | -libvirtd=@sbindir@/libvirtd | |
42 | - | |
43 | -# Source function library. | |
44 | -test ! -r "$sysconfdir"/rc.d/init.d/functions || | |
45 | - . "$sysconfdir"/rc.d/init.d/functions | |
46 | +sysconfdir=/etc | |
47 | +localstatedir=/var | |
48 | +libvirtd=/usr/sbin/libvirtd | |
49 | ||
50 | URIS=default | |
51 | -ON_BOOT=start | |
52 | -ON_SHUTDOWN=suspend | |
53 | -SHUTDOWN_TIMEOUT=0 | |
54 | +ON_BOOT=ignore | |
55 | +ON_SHUTDOWN=shutdown | |
56 | +SHUTDOWN_TIMEOUT=30 | |
57 | ||
58 | -test -f "$sysconfdir"/sysconfig/libvirt-guests && . "$sysconfdir"/sysconfig/libvirt-guests | |
59 | +test -f "$sysconfdir"/default/libvirt-guests && . "$sysconfdir"/default/libvirt-guests | |
60 | ||
61 | LISTFILE="$localstatedir"/lib/libvirt/libvirt-guests | |
62 | -VAR_SUBSYS_LIBVIRT_GUESTS="$localstatedir"/lock/subsys/libvirt-guests | |
63 | +VAR_SUBSYS_LIBVIRT_GUESTS="$localstatedir"/lock/libvirt-guests | |
64 | ||
65 | RETVAL=0 | |
66 | ||
67 | @@ -129,7 +115,7 @@ start() { | |
68 | [ -f "$LISTFILE" ] || { started; return 0; } | |
69 | ||
70 | if [ "x$ON_BOOT" != xstart ]; then | |
71 | - echo $"libvirt-guests is configured not to start any guests on boot" | |
72 | + echo "libvirt-guests is configured not to start any guests on boot" | |
73 | rm -f "$LISTFILE" | |
74 | started | |
75 | return 0 | |
76 | @@ -144,20 +130,20 @@ start() { | |
77 | fi | |
78 | done | |
79 | if ! $configured; then | |
80 | - echo $"Ignoring guests on $uri URI" | |
81 | + echo "Ignoring guests on $uri URI" | |
82 | continue | |
83 | fi | |
84 | ||
85 | - echo $"Resuming guests on $uri URI..." | |
86 | + echo "Resuming guests on $uri URI..." | |
87 | for guest in $list; do | |
88 | name=$(guest_name $uri $guest) | |
89 | - echo -n $"Resuming guest $name: " | |
90 | + echo -n "Resuming guest $name: " | |
91 | if guest_is_on $uri $guest; then | |
92 | if $guest_running; then | |
93 | - echo $"already active" | |
94 | + echo "already active" | |
95 | else | |
96 | retval run_virsh $uri start "$name" >/dev/null && \ | |
97 | - echo $"done" | |
98 | + echo "done" | |
99 | fi | |
100 | fi | |
101 | done | |
102 | @@ -173,7 +159,7 @@ suspend_guest() | |
103 | guest=$2 | |
104 | ||
105 | name=$(guest_name $uri $guest) | |
106 | - label=$"Suspending $name: " | |
107 | + label="Suspending $name: " | |
108 | echo -n "$label" | |
109 | run_virsh $uri managedsave $guest >/dev/null & | |
110 | virsh_pid=$! | |
111 | @@ -188,7 +174,7 @@ suspend_guest() | |
112 | printf '\r%s%-12s ' "$label" "..." | |
113 | fi | |
114 | done | |
115 | - retval wait $virsh_pid && printf '\r%s%-12s\n' "$label" $"done" | |
116 | + retval wait $virsh_pid && printf '\r%s%-12s\n' "$label" "done" | |
117 | } | |
118 | ||
119 | shutdown_guest() | |
120 | @@ -197,7 +183,7 @@ shutdown_guest() | |
121 | guest=$2 | |
122 | ||
123 | name=$(guest_name $uri $guest) | |
124 | - label=$"Shutting down $name: " | |
125 | + label="Shutting down $name: " | |
126 | echo -n "$label" | |
127 | retval run_virsh $uri shutdown $guest >/dev/null || return | |
128 | timeout=$SHUTDOWN_TIMEOUT | |
129 | @@ -211,9 +197,9 @@ shutdown_guest() | |
130 | ||
131 | if guest_is_on $uri $guest; then | |
132 | if $guest_running; then | |
133 | - printf '\r%s%-12s\n' "$label" $"failed to shutdown in time" | |
134 | + printf '\r%s%-12s\n' "$label" "failed to shutdown in time" | |
135 | else | |
136 | - printf '\r%s%-12s\n' "$label" $"done" | |
137 | + printf '\r%s%-12s\n' "$label" "done" | |
138 | fi | |
139 | fi | |
140 | } | |
141 | @@ -226,7 +212,7 @@ stop() { | |
142 | if [ "x$ON_SHUTDOWN" = xshutdown ]; then | |
143 | suspending=false | |
144 | if [ $SHUTDOWN_TIMEOUT -le 0 ]; then | |
145 | - echo $"Shutdown action requested but SHUTDOWN_TIMEOUT was not set" | |
146 | + echo "Shutdown action requested but SHUTDOWN_TIMEOUT was not set" | |
147 | RETVAL=6 | |
148 | return | |
149 | fi | |
150 | @@ -234,10 +220,10 @@ stop() { | |
151 | ||
152 | : >"$LISTFILE" | |
153 | for uri in $URIS; do | |
154 | - echo -n $"Running guests on $uri URI: " | |
155 | + echo -n "Running guests on $uri URI: " | |
156 | ||
157 | if [ "x$uri" = xdefault ] && [ ! -x "$libvirtd" ]; then | |
158 | - echo $"libvirtd not installed; skipping this URI." | |
159 | + echo "libvirtd not installed; skipping this URI." | |
160 | continue | |
161 | fi | |
162 | ||
163 | @@ -250,7 +236,7 @@ stop() { | |
164 | empty=false | |
165 | done | |
166 | if $empty; then | |
167 | - echo $"no running guests." | |
168 | + echo "no running guests." | |
169 | else | |
170 | echo | |
171 | echo $uri $list >>"$LISTFILE" | |
172 | @@ -260,9 +246,9 @@ stop() { | |
173 | ||
174 | while read uri list; do | |
175 | if $suspending; then | |
176 | - echo $"Suspending guests on $uri URI..." | |
177 | + echo "Suspending guests on $uri URI..." | |
178 | else | |
179 | - echo $"Shutting down guests on $uri URI..." | |
180 | + echo "Shutting down guests on $uri URI..." | |
181 | fi | |
182 | ||
183 | for guest in $list; do | |
184 | @@ -286,17 +272,16 @@ gueststatus() { | |
185 | ||
186 | # rh_status | |
187 | # Display current status: whether saved state exists, and whether start | |
188 | -# has been executed. We cannot use status() from the functions library, | |
189 | -# since there is no external daemon process matching this init script. | |
190 | +# has been executed. | |
191 | rh_status() { | |
192 | if [ -f "$LISTFILE" ]; then | |
193 | - echo $"stopped, with saved guests" | |
194 | + echo "stopped, with saved guests" | |
195 | RETVAL=3 | |
196 | else | |
197 | if [ -f "$VAR_SUBSYS_LIBVIRT_GUESTS" ]; then | |
198 | - echo $"started" | |
199 | + echo "started" | |
200 | else | |
201 | - echo $"stopped, with no saved guests" | |
202 | + echo "stopped, with no saved guests" | |
203 | fi | |
204 | RETVAL=0 | |
205 | fi | |
206 | @@ -305,7 +290,7 @@ rh_status() { | |
207 | # usage [val] | |
208 | # Display usage string, then exit with VAL (defaults to 2). | |
209 | usage() { | |
210 | - echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|gueststatus|shutdown}" | |
211 | + echo "Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|gueststatus|shutdown}" | |
212 | exit ${1-2} | |
213 | } | |
214 | ||
215 | diff --git a/tools/libvirt-guests.sysconf b/tools/libvirt-guests.sysconf | |
216 | index cd58728..53d89bd 100644 | |
217 | --- a/tools/libvirt-guests.sysconf | |
218 | +++ b/tools/libvirt-guests.sysconf | |
219 | @@ -8,7 +8,7 @@ | |
220 | # - ignore libvirt-guests init script won't start any guest on boot, however, | |
221 | # guests marked as autostart will still be automatically started by | |
222 | # libvirtd | |
223 | -#ON_BOOT=start | |
224 | +#ON_BOOT=ignore | |
225 | ||
226 | # action taken on host shutdown | |
227 | # - suspend all running guests are suspended using virsh managedsave | |
228 | @@ -18,7 +18,7 @@ | |
229 | # which just needs a long time to shutdown. When setting | |
230 | # ON_SHUTDOWN=shutdown, you must also set SHUTDOWN_TIMEOUT to a | |
231 | # value suitable for your guests. | |
232 | -#ON_SHUTDOWN=suspend | |
233 | +#ON_SHUTDOWN=shutdown | |
234 | ||
235 | # number of seconds we're willing to wait for a guest to shut down | |
236 | -#SHUTDOWN_TIMEOUT=0 | |
237 | +#SHUTDOWN_TIMEOUT=30 | |
238 | -- |
0 | From: =?UTF-8?q?Laurent=20L=C3=A9onard?= <laurent@open-minds.org> | |
1 | Date: Tue, 4 Jan 2011 19:13:56 +0100 | |
2 | Subject: [PATCH] libvirt-guests: remove bashisms | |
3 | ||
4 | * tools/libvirt-guests.init.sh: Use only POSIX shell features, which | |
5 | includes using gettext.sh for translation rather than $"". | |
6 | * tools/Makefile.am (libvirt-guests.init): Supply a few more substitutions. | |
7 | * po/POTFILES.in: Mark that libvirt-guests.init needs translation. | |
8 | ||
9 | Signed-off-by: Eric Blake <eblake@redhat.com> | |
10 | ||
11 | Origin: upstream, http://libvirt.org/git/?p=libvirt.git;a=commit;h=a9e31a476948bfcf27a2cca1ffa78d6a1b4b939c | |
12 | --- | |
13 | po/POTFILES.in | 1 + | |
14 | tools/Makefile.am | 9 +++-- | |
15 | tools/libvirt-guests.init.in | 72 ++++++++++++++++++++++++----------------- | |
16 | 3 files changed, 49 insertions(+), 33 deletions(-) | |
17 | ||
18 | diff --git a/po/POTFILES.in b/po/POTFILES.in | |
19 | index 3d7bc8b..9d9a86f 100644 | |
20 | --- a/po/POTFILES.in | |
21 | +++ b/po/POTFILES.in | |
22 | @@ -118,4 +118,5 @@ src/xen/xs_internal.c | |
23 | src/xenapi/xenapi_driver.c | |
24 | src/xenapi/xenapi_utils.c | |
25 | tools/console.c | |
26 | +tools/libvirt-guests.init.in | |
27 | tools/virsh.c | |
28 | diff --git a/tools/Makefile.am b/tools/Makefile.am | |
29 | index 271c11b..87cf9bd 100644 | |
30 | --- a/tools/Makefile.am | |
31 | +++ b/tools/Makefile.am | |
32 | @@ -146,9 +146,12 @@ BUILT_SOURCES += libvirt-guests.init | |
33 | ||
34 | libvirt-guests.init: libvirt-guests.init.in $(top_builddir)/config.status | |
35 | $(AM_V_GEN)sed \ | |
36 | - -e s!\@localstatedir\@!@localstatedir@!g \ | |
37 | - -e s!\@sbindir\@!@sbindir@!g \ | |
38 | - -e s!\@sysconfdir\@!@sysconfdir@!g \ | |
39 | + -e 's!\@PACKAGE\@!$(PACKAGE)!g' \ | |
40 | + -e 's!\@bindir\@!$(bindir)!g' \ | |
41 | + -e 's!\@localedir\@!$(localedir)!g' \ | |
42 | + -e 's!\@localstatedir\@!$(localstatedir)!g' \ | |
43 | + -e 's!\@sbindir\@!$(sbindir)!g' \ | |
44 | + -e 's!\@sysconfdir\@!$(sysconfdir)!g' \ | |
45 | < $< > $@-t && \ | |
46 | chmod a+x $@-t && \ | |
47 | mv $@-t $@ | |
48 | diff --git a/tools/libvirt-guests.init.in b/tools/libvirt-guests.init.in | |
49 | index e28938d..8823d06 100644 | |
50 | --- a/tools/libvirt-guests.init.in | |
51 | +++ b/tools/libvirt-guests.init.in | |
52 | @@ -24,20 +24,27 @@ | |
53 | # See http://libvirt.org | |
54 | # | |
55 | ||
56 | -sysconfdir=@sysconfdir@ | |
57 | -localstatedir=@localstatedir@ | |
58 | -libvirtd=@sbindir@/libvirtd | |
59 | +sysconfdir="@sysconfdir@" | |
60 | +localstatedir="@localstatedir@" | |
61 | +libvirtd="@sbindir@"/libvirtd | |
62 | ||
63 | # Source function library. | |
64 | test ! -r "$sysconfdir"/rc.d/init.d/functions || | |
65 | - . "$sysconfdir"/rc.d/init.d/functions | |
66 | + . "$sysconfdir"/rc.d/init.d/functions | |
67 | + | |
68 | +# Source gettext library. | |
69 | +# Make sure this file is recognized as having translations: _("dummy") | |
70 | +. "@bindir@"/gettext.sh | |
71 | + | |
72 | +export TEXTDOMAIN="@PACKAGE@" TEXTDOMAINDIR="@localedir@" | |
73 | ||
74 | URIS=default | |
75 | ON_BOOT=start | |
76 | ON_SHUTDOWN=suspend | |
77 | SHUTDOWN_TIMEOUT=0 | |
78 | ||
79 | -test -f "$sysconfdir"/sysconfig/libvirt-guests && . "$sysconfdir"/sysconfig/libvirt-guests | |
80 | +test -f "$sysconfdir"/sysconfig/libvirt-guests && | |
81 | + . "$sysconfdir"/sysconfig/libvirt-guests | |
82 | ||
83 | LISTFILE="$localstatedir"/lib/libvirt/libvirt-guests | |
84 | VAR_SUBSYS_LIBVIRT_GUESTS="$localstatedir"/lock/subsys/libvirt-guests | |
85 | @@ -129,7 +136,8 @@ start() { | |
86 | [ -f "$LISTFILE" ] || { started; return 0; } | |
87 | ||
88 | if [ "x$ON_BOOT" != xstart ]; then | |
89 | - echo $"libvirt-guests is configured not to start any guests on boot" | |
90 | + gettext "libvirt-guests is configured not to start any guests on boot" | |
91 | + echo | |
92 | rm -f "$LISTFILE" | |
93 | started | |
94 | return 0 | |
95 | @@ -144,20 +152,20 @@ start() { | |
96 | fi | |
97 | done | |
98 | if ! $configured; then | |
99 | - echo $"Ignoring guests on $uri URI" | |
100 | + eval_gettext "Ignoring guests on \$uri URI"; echo | |
101 | continue | |
102 | fi | |
103 | ||
104 | - echo $"Resuming guests on $uri URI..." | |
105 | + eval_gettext "Resuming guests on \$uri URI..."; echo | |
106 | for guest in $list; do | |
107 | name=$(guest_name $uri $guest) | |
108 | - echo -n $"Resuming guest $name: " | |
109 | + eval_gettext "Resuming guest \$name: " | |
110 | if guest_is_on $uri $guest; then | |
111 | if $guest_running; then | |
112 | - echo $"already active" | |
113 | + gettext "already active"; echo | |
114 | else | |
115 | retval run_virsh $uri start "$name" >/dev/null && \ | |
116 | - echo $"done" | |
117 | + gettext "done"; echo | |
118 | fi | |
119 | fi | |
120 | done | |
121 | @@ -173,8 +181,8 @@ suspend_guest() | |
122 | guest=$2 | |
123 | ||
124 | name=$(guest_name $uri $guest) | |
125 | - label=$"Suspending $name: " | |
126 | - echo -n "$label" | |
127 | + label=$(eval_gettext "Suspending \$name: ") | |
128 | + printf %s "$label" | |
129 | run_virsh $uri managedsave $guest >/dev/null & | |
130 | virsh_pid=$! | |
131 | while true; do | |
132 | @@ -188,7 +196,7 @@ suspend_guest() | |
133 | printf '\r%s%-12s ' "$label" "..." | |
134 | fi | |
135 | done | |
136 | - retval wait $virsh_pid && printf '\r%s%-12s\n' "$label" $"done" | |
137 | + retval wait $virsh_pid && printf '\r%s%-12s\n' "$label" "$(gettext "done")" | |
138 | } | |
139 | ||
140 | shutdown_guest() | |
141 | @@ -197,13 +205,13 @@ shutdown_guest() | |
142 | guest=$2 | |
143 | ||
144 | name=$(guest_name $uri $guest) | |
145 | - label=$"Shutting down $name: " | |
146 | - echo -n "$label" | |
147 | + label=$(eval_gettext "Shutting down \$name: ") | |
148 | + printf %s "$label" | |
149 | retval run_virsh $uri shutdown $guest >/dev/null || return | |
150 | timeout=$SHUTDOWN_TIMEOUT | |
151 | while [ $timeout -gt 0 ]; do | |
152 | sleep 1 | |
153 | - timeout=$[timeout - 1] | |
154 | + timeout=$((timeout - 1)) | |
155 | guest_is_on $uri $guest || return | |
156 | $guest_running || break | |
157 | printf '\r%s%-12d ' "$label" $timeout | |
158 | @@ -211,9 +219,10 @@ shutdown_guest() | |
159 | ||
160 | if guest_is_on $uri $guest; then | |
161 | if $guest_running; then | |
162 | - printf '\r%s%-12s\n' "$label" $"failed to shutdown in time" | |
163 | + printf '\r%s%-12s\n' "$label" \ | |
164 | + "$(gettext "failed to shutdown in time")" | |
165 | else | |
166 | - printf '\r%s%-12s\n' "$label" $"done" | |
167 | + printf '\r%s%-12s\n' "$label" "$(gettext "done")" | |
168 | fi | |
169 | fi | |
170 | } | |
171 | @@ -226,7 +235,8 @@ stop() { | |
172 | if [ "x$ON_SHUTDOWN" = xshutdown ]; then | |
173 | suspending=false | |
174 | if [ $SHUTDOWN_TIMEOUT -le 0 ]; then | |
175 | - echo $"Shutdown action requested but SHUTDOWN_TIMEOUT was not set" | |
176 | + gettext "Shutdown action requested but SHUTDOWN_TIMEOUT was not set" | |
177 | + echo | |
178 | RETVAL=6 | |
179 | return | |
180 | fi | |
181 | @@ -234,10 +244,10 @@ stop() { | |
182 | ||
183 | : >"$LISTFILE" | |
184 | for uri in $URIS; do | |
185 | - echo -n $"Running guests on $uri URI: " | |
186 | + eval_gettext "Running guests on \$uri URI: " | |
187 | ||
188 | if [ "x$uri" = xdefault ] && [ ! -x "$libvirtd" ]; then | |
189 | - echo $"libvirtd not installed; skipping this URI." | |
190 | + gettext "libvirtd not installed; skipping this URI."; echo | |
191 | continue | |
192 | fi | |
193 | ||
194 | @@ -246,11 +256,11 @@ stop() { | |
195 | empty=true | |
196 | for uuid in $list; do | |
197 | $empty || printf ", " | |
198 | - echo -n $(guest_name $uri $uuid) | |
199 | + printf %s "$(guest_name $uri $uuid)" | |
200 | empty=false | |
201 | done | |
202 | if $empty; then | |
203 | - echo $"no running guests." | |
204 | + gettext "no running guests."; echo | |
205 | else | |
206 | echo | |
207 | echo $uri $list >>"$LISTFILE" | |
208 | @@ -260,9 +270,9 @@ stop() { | |
209 | ||
210 | while read uri list; do | |
211 | if $suspending; then | |
212 | - echo $"Suspending guests on $uri URI..." | |
213 | + eval_gettext "Suspending guests on \$uri URI..."; echo | |
214 | else | |
215 | - echo $"Shutting down guests on $uri URI..." | |
216 | + eval_gettext "Shutting down guests on \$uri URI..."; echo | |
217 | fi | |
218 | ||
219 | for guest in $list; do | |
220 | @@ -290,13 +300,13 @@ gueststatus() { | |
221 | # since there is no external daemon process matching this init script. | |
222 | rh_status() { | |
223 | if [ -f "$LISTFILE" ]; then | |
224 | - echo $"stopped, with saved guests" | |
225 | + gettext "stopped, with saved guests"; echo | |
226 | RETVAL=3 | |
227 | else | |
228 | if [ -f "$VAR_SUBSYS_LIBVIRT_GUESTS" ]; then | |
229 | - echo $"started" | |
230 | + gettext "started"; echo | |
231 | else | |
232 | - echo $"stopped, with no saved guests" | |
233 | + gettext "stopped, with no saved guests"; echo | |
234 | fi | |
235 | RETVAL=0 | |
236 | fi | |
237 | @@ -305,7 +315,9 @@ rh_status() { | |
238 | # usage [val] | |
239 | # Display usage string, then exit with VAL (defaults to 2). | |
240 | usage() { | |
241 | - echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|gueststatus|shutdown}" | |
242 | + program_name=$0 | |
243 | + eval_gettext "Usage: \$program_name {start|stop|status|restart|"\ | |
244 | +"condrestart|try-restart|reload|force-reload|gueststatus|shutdown}"; echo | |
245 | exit ${1-2} | |
246 | } | |
247 | ||
248 | -- |
0 | From: =?UTF-8?q?Laurent=20L=C3=A9onard?= <laurent@open-minds.org> | |
1 | Date: Thu, 9 Dec 2010 22:36:29 +0100 | |
2 | Subject: [PATCH] Debianize libvirt-guests | |
3 | ||
4 | Origin: vendor | |
5 | --- | |
6 | tools/libvirt-guests.init.in | 79 +++++++++++++++++------------------------- | |
7 | tools/libvirt-guests.sysconf | 6 ++-- | |
8 | 2 files changed, 35 insertions(+), 50 deletions(-) | |
9 | ||
10 | diff --git a/tools/libvirt-guests.init.in b/tools/libvirt-guests.init.in | |
11 | index e28938d..0fe82fb 100644 | |
12 | --- a/tools/libvirt-guests.init.in | |
13 | +++ b/tools/libvirt-guests.init.in | |
14 | @@ -4,8 +4,8 @@ | |
15 | # | |
16 | ### BEGIN INIT INFO | |
17 | # Provides: libvirt-guests | |
18 | -# Required-Start: libvirtd | |
19 | -# Required-Stop: libvirtd | |
20 | +# Required-Start: $remote_fs libvirt-bin | |
21 | +# Required-Stop: $remote_fs libvirt-bin | |
22 | # Default-Start: 2 3 4 5 | |
23 | # Default-Stop: 0 1 6 | |
24 | # Short-Description: suspend/resume libvirt guests on shutdown/boot | |
25 | @@ -14,33 +14,19 @@ | |
26 | # See http://libvirt.org | |
27 | ### END INIT INFO | |
28 | ||
29 | -# the following is chkconfig init header | |
30 | -# | |
31 | -# libvirt-guests: suspend/resume libvirt guests on shutdown/boot | |
32 | -# | |
33 | -# chkconfig: 345 99 01 | |
34 | -# description: This is a script for suspending active libvirt guests \ | |
35 | -# on shutdown and resuming them on next boot \ | |
36 | -# See http://libvirt.org | |
37 | -# | |
38 | - | |
39 | -sysconfdir=@sysconfdir@ | |
40 | -localstatedir=@localstatedir@ | |
41 | -libvirtd=@sbindir@/libvirtd | |
42 | - | |
43 | -# Source function library. | |
44 | -test ! -r "$sysconfdir"/rc.d/init.d/functions || | |
45 | - . "$sysconfdir"/rc.d/init.d/functions | |
46 | +sysconfdir=/etc | |
47 | +localstatedir=/var | |
48 | +libvirtd=/usr/sbin/libvirtd | |
49 | ||
50 | URIS=default | |
51 | -ON_BOOT=start | |
52 | -ON_SHUTDOWN=suspend | |
53 | -SHUTDOWN_TIMEOUT=0 | |
54 | +ON_BOOT=ignore | |
55 | +ON_SHUTDOWN=shutdown | |
56 | +SHUTDOWN_TIMEOUT=30 | |
57 | ||
58 | -test -f "$sysconfdir"/sysconfig/libvirt-guests && . "$sysconfdir"/sysconfig/libvirt-guests | |
59 | +test -f "$sysconfdir"/default/libvirt-guests && . "$sysconfdir"/default/libvirt-guests | |
60 | ||
61 | LISTFILE="$localstatedir"/lib/libvirt/libvirt-guests | |
62 | -VAR_SUBSYS_LIBVIRT_GUESTS="$localstatedir"/lock/subsys/libvirt-guests | |
63 | +VAR_SUBSYS_LIBVIRT_GUESTS="$localstatedir"/lock/libvirt-guests | |
64 | ||
65 | RETVAL=0 | |
66 | ||
67 | @@ -129,7 +115,7 @@ start() { | |
68 | [ -f "$LISTFILE" ] || { started; return 0; } | |
69 | ||
70 | if [ "x$ON_BOOT" != xstart ]; then | |
71 | - echo $"libvirt-guests is configured not to start any guests on boot" | |
72 | + echo "libvirt-guests is configured not to start any guests on boot" | |
73 | rm -f "$LISTFILE" | |
74 | started | |
75 | return 0 | |
76 | @@ -144,20 +130,20 @@ start() { | |
77 | fi | |
78 | done | |
79 | if ! $configured; then | |
80 | - echo $"Ignoring guests on $uri URI" | |
81 | + echo "Ignoring guests on $uri URI" | |
82 | continue | |
83 | fi | |
84 | ||
85 | - echo $"Resuming guests on $uri URI..." | |
86 | + echo "Resuming guests on $uri URI..." | |
87 | for guest in $list; do | |
88 | name=$(guest_name $uri $guest) | |
89 | - echo -n $"Resuming guest $name: " | |
90 | + echo -n "Resuming guest $name: " | |
91 | if guest_is_on $uri $guest; then | |
92 | if $guest_running; then | |
93 | - echo $"already active" | |
94 | + echo "already active" | |
95 | else | |
96 | retval run_virsh $uri start "$name" >/dev/null && \ | |
97 | - echo $"done" | |
98 | + echo "done" | |
99 | fi | |
100 | fi | |
101 | done | |
102 | @@ -173,7 +159,7 @@ suspend_guest() | |
103 | guest=$2 | |
104 | ||
105 | name=$(guest_name $uri $guest) | |
106 | - label=$"Suspending $name: " | |
107 | + label="Suspending $name: " | |
108 | echo -n "$label" | |
109 | run_virsh $uri managedsave $guest >/dev/null & | |
110 | virsh_pid=$! | |
111 | @@ -188,7 +174,7 @@ suspend_guest() | |
112 | printf '\r%s%-12s ' "$label" "..." | |
113 | fi | |
114 | done | |
115 | - retval wait $virsh_pid && printf '\r%s%-12s\n' "$label" $"done" | |
116 | + retval wait $virsh_pid && printf '\r%s%-12s\n' "$label" "done" | |
117 | } | |
118 | ||
119 | shutdown_guest() | |
120 | @@ -197,7 +183,7 @@ shutdown_guest() | |
121 | guest=$2 | |
122 | ||
123 | name=$(guest_name $uri $guest) | |
124 | - label=$"Shutting down $name: " | |
125 | + label="Shutting down $name: " | |
126 | echo -n "$label" | |
127 | retval run_virsh $uri shutdown $guest >/dev/null || return | |
128 | timeout=$SHUTDOWN_TIMEOUT | |
129 | @@ -211,9 +197,9 @@ shutdown_guest() | |
130 | ||
131 | if guest_is_on $uri $guest; then | |
132 | if $guest_running; then | |
133 | - printf '\r%s%-12s\n' "$label" $"failed to shutdown in time" | |
134 | + printf '\r%s%-12s\n' "$label" "failed to shutdown in time" | |
135 | else | |
136 | - printf '\r%s%-12s\n' "$label" $"done" | |
137 | + printf '\r%s%-12s\n' "$label" "done" | |
138 | fi | |
139 | fi | |
140 | } | |
141 | @@ -226,7 +212,7 @@ stop() { | |
142 | if [ "x$ON_SHUTDOWN" = xshutdown ]; then | |
143 | suspending=false | |
144 | if [ $SHUTDOWN_TIMEOUT -le 0 ]; then | |
145 | - echo $"Shutdown action requested but SHUTDOWN_TIMEOUT was not set" | |
146 | + echo "Shutdown action requested but SHUTDOWN_TIMEOUT was not set" | |
147 | RETVAL=6 | |
148 | return | |
149 | fi | |
150 | @@ -234,10 +220,10 @@ stop() { | |
151 | ||
152 | : >"$LISTFILE" | |
153 | for uri in $URIS; do | |
154 | - echo -n $"Running guests on $uri URI: " | |
155 | + echo -n "Running guests on $uri URI: " | |
156 | ||
157 | if [ "x$uri" = xdefault ] && [ ! -x "$libvirtd" ]; then | |
158 | - echo $"libvirtd not installed; skipping this URI." | |
159 | + echo "libvirtd not installed; skipping this URI." | |
160 | continue | |
161 | fi | |
162 | ||
163 | @@ -250,7 +236,7 @@ stop() { | |
164 | empty=false | |
165 | done | |
166 | if $empty; then | |
167 | - echo $"no running guests." | |
168 | + echo "no running guests." | |
169 | else | |
170 | echo | |
171 | echo $uri $list >>"$LISTFILE" | |
172 | @@ -260,9 +246,9 @@ stop() { | |
173 | ||
174 | while read uri list; do | |
175 | if $suspending; then | |
176 | - echo $"Suspending guests on $uri URI..." | |
177 | + echo "Suspending guests on $uri URI..." | |
178 | else | |
179 | - echo $"Shutting down guests on $uri URI..." | |
180 | + echo "Shutting down guests on $uri URI..." | |
181 | fi | |
182 | ||
183 | for guest in $list; do | |
184 | @@ -286,17 +272,16 @@ gueststatus() { | |
185 | ||
186 | # rh_status | |
187 | # Display current status: whether saved state exists, and whether start | |
188 | -# has been executed. We cannot use status() from the functions library, | |
189 | -# since there is no external daemon process matching this init script. | |
190 | +# has been executed. | |
191 | rh_status() { | |
192 | if [ -f "$LISTFILE" ]; then | |
193 | - echo $"stopped, with saved guests" | |
194 | + echo "stopped, with saved guests" | |
195 | RETVAL=3 | |
196 | else | |
197 | if [ -f "$VAR_SUBSYS_LIBVIRT_GUESTS" ]; then | |
198 | - echo $"started" | |
199 | + echo "started" | |
200 | else | |
201 | - echo $"stopped, with no saved guests" | |
202 | + echo "stopped, with no saved guests" | |
203 | fi | |
204 | RETVAL=0 | |
205 | fi | |
206 | @@ -305,7 +290,7 @@ rh_status() { | |
207 | # usage [val] | |
208 | # Display usage string, then exit with VAL (defaults to 2). | |
209 | usage() { | |
210 | - echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|gueststatus|shutdown}" | |
211 | + echo "Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|gueststatus|shutdown}" | |
212 | exit ${1-2} | |
213 | } | |
214 | ||
215 | diff --git a/tools/libvirt-guests.sysconf b/tools/libvirt-guests.sysconf | |
216 | index cd58728..53d89bd 100644 | |
217 | --- a/tools/libvirt-guests.sysconf | |
218 | +++ b/tools/libvirt-guests.sysconf | |
219 | @@ -8,7 +8,7 @@ | |
220 | # - ignore libvirt-guests init script won't start any guest on boot, however, | |
221 | # guests marked as autostart will still be automatically started by | |
222 | # libvirtd | |
223 | -#ON_BOOT=start | |
224 | +#ON_BOOT=ignore | |
225 | ||
226 | # action taken on host shutdown | |
227 | # - suspend all running guests are suspended using virsh managedsave | |
228 | @@ -18,7 +18,7 @@ | |
229 | # which just needs a long time to shutdown. When setting | |
230 | # ON_SHUTDOWN=shutdown, you must also set SHUTDOWN_TIMEOUT to a | |
231 | # value suitable for your guests. | |
232 | -#ON_SHUTDOWN=suspend | |
233 | +#ON_SHUTDOWN=shutdown | |
234 | ||
235 | # number of seconds we're willing to wait for a guest to shut down | |
236 | -#SHUTDOWN_TIMEOUT=0 | |
237 | +#SHUTDOWN_TIMEOUT=30 | |
238 | -- |