mirror of
https://0xacab.org/liberate/backupninja.git
synced 2024-11-08 11:52:32 +01:00
lib/vserver.in: new function: vservers_exist
handlers/dup: make use of new lib/vserver functionality
This commit is contained in:
parent
96023985bc
commit
299a530734
@ -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.
|
||||
|
39
handlers/dup
39
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__/*}"
|
||||
|
@ -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.
|
||||
##
|
||||
|
Loading…
Reference in New Issue
Block a user