aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog2
-rw-r--r--handlers/dup39
-rw-r--r--lib/vserver.in23
3 files changed, 39 insertions, 25 deletions
diff --git a/ChangeLog b/ChangeLog
index 2e844ad..cf7fc37 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -16,6 +16,7 @@ version 0.9.3 -- unreleased
disabled in backupninja.conf
. now works when multiple vservers names are given (separated by space)
in vsnames config variable
+ . make use of new lib/vserver functionality
ninjahelper changes
rdiff.helper:
. fixed errors in create remote dir
@@ -33,6 +34,7 @@ version 0.9.3 -- unreleased
. init_vservers: canonicalize VROOTDIR (since duplicity et al.
don't follow symlinks)
. init_vservers: warn if vservers are enabled but no vserver is found
+ . new function: vservers_exist
known bugs:
easydialog:
. formDisplay does not return exit status.
diff --git a/handlers/dup b/handlers/dup
index ac7e329..d32fcf2 100644
--- a/handlers/dup
+++ b/handlers/dup
@@ -34,29 +34,20 @@ destdir=${destdir%/}
[ "$include" != "" ] || fatal "No source includes specified"
### vservers stuff ###
-
-# See if vservers are configured.
-# If so, check that the ones listed in $vsnames do exist.
-if [ "$vservers" == "yes" ]; then
- [ -d "$VROOTDIR" ] || fatal "vservers enabled, but $VROOTDIR does not exist!"
- if [ "$vsnames" == "all" ]; then
- vsnames=""
- for vserver in `ls $VROOTDIR | grep -E -v "lost+found|ARCHIVES"`; do
- vsnames="$vserver $vsnames"
- done
- else
- for vserver in $vsnames; do
- [ -d "$VROOTDIR/$vserver" ] || fatal "vserver '$vserver' does not exist."
- done
- fi
- if [ -n "$vsnames" ]; then
- if [ -n "$vsinclude" ]; then
- info "Using vservers '$vsnames'"
- usevserver=1
- fi
- else
- [ -z "$vsinclude" ] || warning 'vsnames is empty, vsinclude configuration lines will be ignored'
- fi
+local usevserver=no
+# If vservers are configured, check that the ones listed in $vsnames do exist.
+if [ $vservers_are_available = yes ]; then
+ if [ "$vsnames" = all ]; then
+ vsnames="$found_vservers"
+ else
+ if ! vservers_exist "$vsnames" ; then
+ fatal "At least one of the vservers listed in vsnames ($vsnames) does not exist."
+ fi
+ fi
+ if [ -n "$vsinclude" ]; then
+ info "Using vservers '$vsnames'"
+ usevserver=yes
+ fi
else
[ -z "$vsinclude" ] || warning 'vservers support disabled in backupninja.conf, vsincludes configuration lines will be ignored'
[ -z "$vsnames" ] || warning 'vservers support disabled in backupninja.conf, vsnames configuration line will be ignored'
@@ -135,7 +126,7 @@ for i in "$include"; do
done
# vsincludes
-if [ $usevserver ]; then
+if [ $usevserver = yes ]; then
for vserver in $vsnames; do
for vi in "$vsinclude"; do
str="${vi//__star__/*}"
diff --git a/lib/vserver.in b/lib/vserver.in
index bb1a152..1c267c6 100644
--- a/lib/vserver.in
+++ b/lib/vserver.in
@@ -74,7 +74,28 @@ init_vservers() {
}
##
-## If the argument is the name of a vserver selected use by the current helper,
+## If all the arguments are existing vservers names, returns 0.
+## Else, returns 1. Also returns 1 if no argument is given.
+##
+vservers_exist() {
+ [ $# -ge 1 ] || return 1
+ local args="$1"
+ local vserver i found
+ for vserver in $args ; do
+ found=no
+ for i in $found_vservers ; do
+ if [ $vserver = $i ]; then
+ found=yes
+ break
+ fi
+ done
+ [ $found = yes ] || return 1
+ done
+ return 0
+}
+
+##
+## If the argument is the name of a vserver selected by the current helper,
## echoes 'on' and returns 0.
## Else, echoes 'off' and returns 1.
##