r3561@krups: intrigeri | 2005-11-15 15:16:50 +0100
[matthijs/upstream/backupninja.git] / src / ninjahelper.in
index 104575944d4a376aae9e5ac9d54d800d2ce2221d..451f38978e91b56a959d89491e1bcd199b9c199a 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!@BASH@
 
 ####################################################
 ## Functions
@@ -23,7 +23,7 @@ function check_perms() {
 ##
 ## returns the next available file name given a file
 ## in the form @CFGDIR@/backup.d/10.sys
-## sets variable $returned_filename
+## sets variable $next_filename
 ##
 get_next_filename() {
   next_filename=$1
@@ -41,7 +41,7 @@ get_next_filename() {
 ## installs packages (passed in as $@) if not present
 ##
 require_packages() {
-       for pkg in "$@"; do
+       for pkg in "$@"; do
           installed=`dpkg -s $pkg | grep 'ok installed'`
        if [ -z "$installed" ]; then 
            booleanBox "install $pkg?" "This backup action requires package $pkg. Do you want to install it now?"
@@ -187,15 +187,39 @@ if [ ! -r "$conffile" ]; then
        echo "Configuration file $conffile not found." 
        exit 1
 fi
+
+# find $scriptdir
 scriptdir=`grep scriptdirectory $conffile | awk '{print $3}'`
-if [ ! -n "$scriptdir" ]; then
-       echo "Cound not find entry 'scriptdirectory' in $conffile" 
-       exit 1
+if [ -z "$scriptdir" ]; then
+        if [ -d "@datadir@" ]; then
+          scriptdir="@datadir@"
+       else
+          echo "Could not find entry 'scriptdirectory' in $conffile" 
+          exit 1
+       fi
+else
+        if [ ! -d "$scriptdir" ]; then
+          echo "Script directory $scriptdir not found." 
+          exit 1
+       fi         
 fi
-if [ ! -d "$scriptdir" ]; then
-       echo "Script directory $scriptdir not found." 
-       exit 1
+
+# find $libdir
+libdir=`grep libdirectory $conffile | awk '{print $3}'`
+if [ -z "$libdir" ]; then
+        if [ -d "@libdir@" ]; then
+          libdir="@libdir@"
+       else
+          echo "Could not find entry 'libdirectory' in $conffile." 
+          exit 1
+       fi
+else
+        if [ ! -d "$libdir" ]; then
+          echo "Lib directory $libdir not found." 
+          exit 1
+       fi
 fi
+
 configdirectory=`grep configdirectory $conffile | awk '{print $3}'`
 if [ ! -n "$configdirectory" ]; then
        echo "Cound not find entry 'configdirectory' in $conffile" 
@@ -206,7 +230,7 @@ if [ ! -d "$configdirectory" ]; then
        exit 1
 fi
 
-. $scriptdir/easydialog.sh
+. $libdir/easydialog
 
 if [ "$UID" != "0" ]; then
        msgBox "warning" "ninjahelper must be run by root!"