X-Git-Url: https://git.stderr.nl/gitweb?p=matthijs%2Fupstream%2Fbackupninja.git;a=blobdiff_plain;f=backupninja;h=b7d4a149e2e73683745e92f224faf899abd1c71f;hp=81b1a17896412ef8eb5e8943291885b5e9ba0907;hb=7a8a4455bed618e18254dcadb319c69a95edd64d;hpb=5e1f333927cb31c5eb589801b23a7ff52739d72a diff --git a/backupninja b/backupninja index 81b1a17..b7d4a14 100755 --- a/backupninja +++ b/backupninja @@ -31,7 +31,7 @@ function setupcolors() { } function colorize() { - if [ "$usecolor" == "yes" ]; then + if [ "$usecolors" == "yes" ]; then local typestr=`echo "$@" | sed 's/\(^[^:]*\).*$/\1/'` [ "$typestr" == "Debug" ] && type=0 [ "$typestr" == "Info" ] && type=1 @@ -58,7 +58,7 @@ function colorize() { # used to capture output from handlers echo_debug_msg=0 -usecolor=yes +usecolors=yes function printmsg() { [ ${#@} -gt 1 ] || return @@ -238,6 +238,7 @@ The following options are available: -t, --test Run in test mode, no actions are actually taken. -n, --now Perform actions now, instead of when they might be scheduled. + --run FILE Execute the specified action file and then exit. When using colored output, there are: EOF debug=1 @@ -306,7 +307,7 @@ function process_action() { _fatals=`cat $bufferfile | grep "^Fatal: " | wc -l` ret=`grep "\(^Warning: \|^Error: \|^Fatal: \)" $bufferfile` - #rm $bufferfile + rm $bufferfile if [ $_fatals != 0 ]; then msg "*failed* -- $file" errormsg="$errormsg\n== failures from $file ==\n\n$ret\n" @@ -316,10 +317,12 @@ function process_action() { elif [ $_warnings != 0 ]; then msg "*warning* -- $file" errormsg="$errormsg\n== warnings from $file ==\n\n$ret\n" - elif [ $retcode == 0 ]; then - msg "success -- $file" else - msg "unknown -- $file" + msg "success -- $file" +# elif [ $retcode == 0 ]; then +# msg "success -- $file" +# else +# msg "unknown -- $file" fi let "fatals += _fatals" @@ -352,11 +355,11 @@ while [ $# -ge 1 ]; do # we shift here to avoid processing the file path shift ;; - --run) + --run) + debug=1 if [ -f $2 ]; then singlerun=$2 processnow=1 - debug=1 else fatal "--run option must be fallowed by a backupninja action file" usage @@ -364,13 +367,19 @@ while [ $# -ge 1 ]; do shift ;; *) + debug=1 fatal "Unknown option $1" usage + exit ;; esac shift done +#if [ $debug ]; then +# usercolors=yes +#fi + ## Load and confirm basic configuration values # bootstrap @@ -420,11 +429,11 @@ errormsg="" if [ "$singlerun" ]; then files=$singlerun else - files=`ls $configdirectory` + files=`find $configdirectory -mindepth 1 ` fi for file in $files; do - [ -f $file ] || continue; + [ -f "$file" ] || continue check_perms $file suffix="${file##*.}" @@ -441,7 +450,7 @@ for file in $files; do msg "*missing handler* -- $file" fi done - + ## mail the messages to the report address if [ $actions_run == 0 ]; then doit=0