|
|
|
|
|
|
|
|
|
|
xen-changelog
[Xen-changelog] Fix the check for non-existence of the save/restore dire
# HG changeset patch
# User emellor@xxxxxxxxxxxxxxxxxxxxxx
# Node ID 20d1a79ebe31fd1073924ab0c78410ffcd20447b
# Parent 0240a69e1f97845145b377f95e68b16d52660221
Fix the check for non-existence of the save/restore directories, by using &&
rather than -a. The former shortcuts at the script level, whereas the latter
does not, which means that the backtick-enclosed arguments are evaluated
regardless of the success of preceding tests.
Tidy the aforementioned test into a function of its own.
Add an implementation of usleep for those systems that only have sleep (Debian,
for example).
Signed-off-by: Ewan Mellor <ewan@xxxxxxxxxxxxx>
diff -r 0240a69e1f97 -r 20d1a79ebe31 tools/examples/init.d/xendomains
--- a/tools/examples/init.d/xendomains Wed Oct 26 13:59:29 2005
+++ b/tools/examples/init.d/xendomains Wed Oct 26 15:59:13 2005
@@ -121,9 +121,34 @@
}
fi
+if ! which usleep >&/dev/null
+then
+ usleep()
+ {
+ if [ -n "$1" ]
+ then
+ sleep $(( $1 / 1000 ))
+ fi
+ }
+fi
+
# Reset status of this service
rc_reset
+##
+# Returns 0 (success) if the given parameter names a directory, and that
+# directory is not empty.
+#
+contains_something()
+{
+ if [ -d "$1" ] && [ `/bin/ls $1 | wc -l` -gt 0 ]
+ then
+ return 0
+ else
+ return 1
+ fi
+}
+
# read name from xen config file
rdname()
{
@@ -133,7 +158,8 @@
rdnames()
{
NAMES=
- if test ! -d $XENDOMAINS_AUTO -o `/bin/ls $XENDOMAINS_AUTO | wc -l` -eq 0;
then
+ if ! contains_something "$XENDOMAINS_AUTO"
+ then
return
fi
for dom in $XENDOMAINS_AUTO/*; do
@@ -177,9 +203,10 @@
return;
fi
- if test "$XENDOMAINS_RESTORE" = "true" -a -n "$XENDOMAINS_SAVE" \
- -a -d $XENDOMAINS_SAVE -a `/bin/ls $XENDOMAINS_SAVE | wc -l` -gt 0;
then
-
+ if [ "$XENDOMAINS_RESTORE" = "true" ] &&
+ contains_something "$XENDOMAINS_SAVE"
+ then
+ mkdir -p $(dirname "$LOCKFILE")
touch $LOCKFILE
echo -n "Restoring Xen domains:"
for dom in $XENDOMAINS_SAVE/*; do
@@ -195,9 +222,8 @@
done
fi
- if test -n "$XENDOMAINS_AUTO" -a -d $XENDOMAINS_AUTO \
- -a `/bin/ls $XENDOMAINS_AUTO | wc -l` -gt 0; then
-
+ if contains_something "$XENDOMAINS_AUTO"
+ then
touch $LOCKFILE
echo -n "Starting auto Xen domains:"
# We expect config scripts for auto starting domains to be in
@@ -378,8 +404,10 @@
check_all_auto_domains_up()
{
- if test -z "$XENDOMAINS_AUTO" -o ! -d "$XENDOMAINS_AUTO" \
- -o `/bin/ls $XENDOMAINS_AUTO | wc -l` -eq 0; then return 0; fi
+ if ! contains_something "$XENDOMAINS_AUTO"
+ then
+ return 0
+ fi
missing=
for nm in $XENDOMAINS_AUTO/*; do
rdname $nm
@@ -399,8 +427,10 @@
check_all_saved_domains_up()
{
- if test -z "$XENDOMAINS_SAVE" -o ! -d "$XENDOMAINS_SAVE" \
- -o `/bin/ls $XENDOMAINS_SAVE | wc -l` -eq 0; then return 0; fi
+ if ! contains_something "$XENDOMAINS_SAVE"
+ then
+ return 0
+ fi
missing=`/bin/ls $XENDOMAINS_SAVE`
echo -n " MISS SAVED: " $missing
return 1
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|
<Prev in Thread] |
Current Thread |
[Next in Thread> |
- [Xen-changelog] Fix the check for non-existence of the save/restore directories, by using &&,
Xen patchbot -unstable <=
|
|
|
|
|