lib/vserver.in: new function: vservers_exist

handlers/dup: make use of new lib/vserver functionality
This commit is contained in:
intrigeri 2006-01-19 21:56:53 +00:00
parent 96023985bc
commit 299a530734
3 changed files with 39 additions and 25 deletions

View File

@ -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.

View File

@ -34,28 +34,19 @@ 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
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
for vserver in $vsnames; do
[ -d "$VROOTDIR/$vserver" ] || fatal "vserver '$vserver' does not exist."
done
if ! vservers_exist "$vsnames" ; then
fatal "At least one of the vservers listed in vsnames ($vsnames) does not exist."
fi
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'
usevserver=yes
fi
else
[ -z "$vsinclude" ] || warning 'vservers support disabled in backupninja.conf, vsincludes configuration lines 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__/*}"

View File

@ -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.
##