lib/vserver.in: enhanced the VROOTDIR discovery
[matthijs/upstream/backupninja.git] / lib / vserver.in
index 4c62291d4aca4b8ddd6f375aa0a9f28b28706695..113e7bf2b3148eac5f4d8bbe7ca85a2c8c9b681b 100644 (file)
@@ -1,3 +1,5 @@
+# -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*-
+
 #####################################################
 ## VSERVERS RELATED FUNCTIONS FOR NINJAHELPER
 ##
@@ -28,7 +30,7 @@ init_vservers() {
    getconf vservers no
    getconf VSERVERINFO /usr/sbin/vserver-info
    getconf VSERVER /usr/sbin/vserver
-   getconf VROOTDIR `if [ -f "$VSERVERINFO" ]; then $VSERVERINFO info SYSINFO |grep vserver-Rootdir | awk '{print $2}'; fi`
+   getconf VROOTDIR `if [ -x "$VSERVERINFO" ]; then $VSERVERINFO info SYSINFO | grep '^ *vserver-Rootdir' | awk '{print $2}'; fi`
    # init this library's global variables
    vservers_are_available=no
    found_vservers=
@@ -88,14 +90,18 @@ choose_one_vserver() {
 }
 
 ##
-## If Vservers are not enabled, exit silently.
+## If Vservers are not enabled, set host_or_vservers='host' and then return 
 ## Else, have the user choose if he/she wants to perform the backup on the host
 ## system or on one Vserver.
 ## Set, respectively, $host_or_vservers to 'host' or 'vservers'.
 ## Returns 1 if cancelled.
 ##
 choose_host_or_one_vserver() {
-   [ "$vservers_are_available" == "yes" ] || return
+   if [ "$vservers_are_available" != "yes" ] 
+   then
+       host_or_vservers='host'
+       return
+   fi
    local title=$1
    # if there is one, set the previously chosen item as the default
    [ -n "$host_or_vservers" ] && setDefault $host_or_vservers
@@ -114,7 +120,7 @@ choose_host_or_one_vserver() {
 }
 
 ##
-## If Vservers are not enabled, exit silently.
+## If Vservers are not enabled, set host_or_vservers='host' and then return
 ## Else, have the user choose the target he/she wants to perform the backup on:
 ##   - host system only;
 ##   - some vservers only;
@@ -123,7 +129,11 @@ choose_host_or_one_vserver() {
 ## Returns 1 if cancelled.
 ##
 choose_host_or_vservers_or_both() {
-   [ "$vservers_are_available" == "yes" ] || return
+   if [ "$vservers_are_available" != "yes" ] 
+   then
+       host_or_vservers='host'
+       return
+   fi
    local title=$1
    # if there is one, set the previously chosen item as the default
    [ -n "$host_or_vservers" ] && setDefault $host_or_vservers