X-Git-Url: https://git.stderr.nl/gitweb?p=matthijs%2Fupstream%2Fbackupninja.git;a=blobdiff_plain;f=src%2Fninjahelper.in;h=2a7faa90c6f905b9a29e87c339d8fa88d84a408e;hp=e9b4f9ee710c28e6be3ab670831db06a1f1998ab;hb=78884142e7cdaaf3e1f5571b1f28d2ea5a520b30;hpb=90316a33524fe051cbe110904391f317df13a7ac diff --git a/src/ninjahelper.in b/src/ninjahelper.in index e9b4f9e..2a7faa9 100755 --- a/src/ninjahelper.in +++ b/src/ninjahelper.in @@ -1,26 +1,10 @@ #!@BASH@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: #################################################### ## Functions -function check_perms() { - local file=$1 - local perms=`ls -ld $file` - group_w_perm=${perms:5:1} - world_w_perm=${perms:8:1} - if [ "$group_w_perm" == "w" -o "$world_w_perm" == "w" ]; then - echo $perms - echo "helper scripts must not be group or world writable! Dying on file $file" - exit - fi - if [ `ls -ld $file | awk '{print $3}'` != "root" ]; then - echo "helper scripts must be owned by root! Dying on file $file" - exit - fi -} - - ## ## returns the next available file name given a file ## in the form @CFGDIR@/backup.d/10.sys @@ -44,7 +28,7 @@ get_next_filename() { require_packages() { for pkg in "$@"; do installed=`dpkg -s $pkg | grep 'ok installed'` - if [ -z "$installed" ]; then + if [ -z "$installed" ]; then booleanBox "install $pkg?" "This backup action requires package $pkg. Do you want to install it now?" if [ $? = 0 ]; then apt-get install $pkg @@ -71,7 +55,7 @@ donew() { listItem $helper_function "$helper_info" done listDisplay menu - + [ $? = 1 ] && return result="$REPLY" [ "$result" = "return" -o "$result" = "" ] && return @@ -79,10 +63,10 @@ donew() { $run_wizard result=$? # 0 is ok, 1 is cancel, anything else is bad. - if [ $result != 1 -a $result != 0 ]; then + if [ $result != 1 -a $result != 0 ]; then echo "An error occurred ($result), bailing out. Hit return to continue." read - fi + fi } do_rm_action() { @@ -101,17 +85,17 @@ do_run() { do_xedit() { if [ -z "$EDITOR" -o ! -x "`which $EDITOR`" ]; then if [ -h /etc/alternatives/editor -a -x "`readlink /etc/alternatives/editor`" ]; then - EDITOR="`readlink /etc/alternatives/editor`" + EDITOR="`readlink /etc/alternatives/editor`" elif [ -x "`which nano`" ]; then - EDITOR="`which nano`" + EDITOR="`which nano`" elif [ -x "`which vim`" ]; then - EDITOR="`which vim`" + EDITOR="`which vim`" elif [ -x "`which vi`" ]; then - EDITOR="`which vi`" + EDITOR="`which vi`" else - echo "No suitable editor found." - echo "Please define $EDITOR or configure /etc/alternatives/editor." - exit + echo "No suitable editor found." + echo "Please define $EDITOR or configure /etc/alternatives/editor." + exit fi fi $EDITOR $1 @@ -155,17 +139,17 @@ doaction() { name "change the filename" \ run "run this action now" \ test "do a test run" \ - kill "remove this action" + kill "remove this action" [ $? = 1 ] && return; result="$REPLY" case "$result" in - "view") dialog --textbox $action 0 0;; + "view") dialog --textbox $action 0 0;; "xedit") do_xedit $action;; "disable") do_disable $action; return;; "enable") do_enable $action; return;; "name") do_rename $action; return;; "run") do_run $action;; - "test") do_run_test $action;; + "test") do_run_test $action;; "kill") do_rm_action $action; return;; "main") return;; esac @@ -195,22 +179,22 @@ fi # bootstrap conffile="@CFGDIR@/backupninja.conf" if [ ! -r "$conffile" ]; then - echo "Configuration file $conffile not found." + echo "Configuration file $conffile not found." exit 1 fi # find $libdirectory -libdirectory=`grep '^libdirectory' $conffile | awk '{print $3}'` +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." + echo "Could not find entry 'libdirectory' in $conffile." exit 1 fi else if [ ! -d "$libdirectory" ]; then - echo "Lib directory $libdirectory not found." + echo "Lib directory $libdirectory not found." exit 1 fi fi @@ -238,7 +222,6 @@ getconf scriptdirectory @datadir@ # load all the helpers HELPERS="" for file in `find $scriptdirectory -follow -name '*.helper'`; do - check_perms $file . $file if [ $? != 0 ]; then echo "An error occurred while loading $file. Hit return to continue." @@ -265,7 +248,7 @@ done menuBox "main menu" "Select a backup action for more options, or create a new action:" $menulist \ new "create a new backup action" \ - quit "leave ninjahelper" + quit "leave ninjahelper" [ $? = 1 -o $? = 255 ] && exit 0;