sys: Warn when vsnames is set but vserver support is disabled in backupninja.conf.
[matthijs/upstream/backupninja.git] / handlers / sys.in
index 24ebbe11512a72041d30a94844d4b89b9c1db62b..5f3447b866472ee6b8c74da3416ee19e837d29f0 100755 (executable)
@@ -95,6 +95,11 @@ if [ $vservers_are_available = yes ]; then
    fi
    info "Using vservers '$vsnames'"
    usevserver=yes
+else
+   # Get the config value again, but now without a default value
+   getconf vsnames
+   [ -z "$vsnames" ] || warning 'vservers support disabled in backupninja.conf, vsnames configuration line will be ignored'
+
 fi
 
 ## PACKAGES ##############################
@@ -116,7 +121,7 @@ if [ "$packages" == "yes" ]; then
             continue
          fi
          # is $packagemgr available inside $vserver ?
-         if [ ! -x "$VROOTDIR/$vserver`$VSERVER $vserver exec which $packagemgr`" ]; then
+         if [ ! -x "${VROOTDIR}/${vserver}${packagemgr}" ]; then
             warning "can't find $packagemgr in vserver $vserver, skipping installed packages report."
          else
             # don't expand * since it can be used in $packagemgroptions
@@ -126,12 +131,21 @@ if [ "$packages" == "yes" ]; then
             set +o noglob
          fi
          # is $debconfgetselections available inside $vserver ?
-         if [ -z "`$VSERVER $vserver exec which debconf-get-selections`" ]; then
-            warning "can't find debconf-get-selections in vserver $vserver, skipping package selection states."
+         found=no
+         # case #1: it is available on the host, is it available inside $vserver ?
+         if [ -n "$debconfgetselections" ]; then
+            [ -x "${VROOTDIR}/${vserver}${debconfgetselections}" ] && found=yes
+         # case #2: it is not available on the host, is it available inside $vserver ?
+         else
+            [ -n "`$VSERVER $vserver exec which debconf-get-selections`" ] && found=yes
+         fi
+         if [ "$found" != yes ]; then
+            warning "can't find debconf-get-selections in vserver $vserver, skipping package selection states. You may want to install the debconf-utils package."
          else
             debug "$VSERVER $vserver exec $debconfgetselections > $VROOTDIR/$vserver$selectionsfile"
             $VSERVER $vserver exec $debconfgetselections > $VROOTDIR/$vserver$selectionsfile || fatal "can not save debconf-get-selections info to $selectionsfile"
          fi
+         unset found
       done
    fi
    
@@ -146,7 +160,7 @@ if [ "$packages" == "yes" ]; then
       set +o noglob
    fi
    if [ -z "$debconfgetselections" ]; then
-      warning "can't find debconf-get-selections, skipping package selection states."
+      warning "can't find debconf-get-selections, skipping package selection states. You might want to install the debconf-utils package."
    else
       debug "$debconfgetselections > $selectionsfile"
       $debconfgetselections > $selectionsfile || fatal "can not save $debconfgetselections info to $selectionsfile"