X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=src%2Fninjahelper.in;h=e39e79f13339c9d1c517966960470c718943f06f;hb=c26bd0e12d52504f0ac10e8e61f9316a900374eb;hp=104575944d4a376aae9e5ac9d54d800d2ce2221d;hpb=5c72b9d23c8233de3892c8fa88f927a7eb8165dc;p=matthijs%2Fupstream%2Fbackupninja.git diff --git a/src/ninjahelper.in b/src/ninjahelper.in index 1045759..e39e79f 100755 --- a/src/ninjahelper.in +++ b/src/ninjahelper.in @@ -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?" @@ -58,6 +58,9 @@ require_packages() { ## menu for the wizards ## donew() { + # (re-)initialize vservers support + init_vservers + # menu listBegin "new action menu" "select an action to create" listItem return "return to main menu" for data in $HELPERS; do @@ -182,40 +185,48 @@ if [ ! -x "`which dialog`" ]; then done fi +# bootstrap conffile="@CFGDIR@/backupninja.conf" if [ ! -r "$conffile" ]; then echo "Configuration file $conffile not found." exit 1 fi -scriptdir=`grep scriptdirectory $conffile | awk '{print $3}'` -if [ ! -n "$scriptdir" ]; then - echo "Cound not find entry 'scriptdirectory' in $conffile" - exit 1 -fi -if [ ! -d "$scriptdir" ]; then - echo "Script directory $scriptdir not found." - exit 1 -fi -configdirectory=`grep configdirectory $conffile | awk '{print $3}'` -if [ ! -n "$configdirectory" ]; then - echo "Cound not find entry 'configdirectory' in $conffile" - exit 1 -fi -if [ ! -d "$configdirectory" ]; then - echo "Configuration directory $configdirectory not found." - exit 1 + +# find $libdirectory +libdirectory=`grep '^libdirectory' $conffile | awk '{print $3}'` +if [ -z "$libdirectory" ]; then + if [ -d "@libdir@" ]; then + libdirectory="@libdir@" + else + echo "Could not find entry 'libdirectory' in $conffile." + exit 1 + fi +else + if [ ! -d "$libdirectory" ]; then + echo "Lib directory $libdirectory not found." + exit 1 + fi fi -. $scriptdir/easydialog.sh +# include shared functions +. $libdirectory/easydialog +. $libdirectory/tools +. $libdirectory/vserver +# am I running as root? if [ "$UID" != "0" ]; then - msgBox "warning" "ninjahelper must be run by root!" + msgBox "warning" "`basename $0` must be run by root!" exit 1 fi +# get global config options (second param is the default) +setfile $conffile +getconf configdirectory @CFGDIR@/backup.d +getconf scriptdirectory @datadir@ + # load all the helpers HELPERS="" -for file in `find $scriptdir -follow -name '*.helper'`; do +for file in `find $scriptdirectory -follow -name '*.helper'`; do check_perms $file . $file done