Adding optional report of infos sent by handlers in the email (closes #563734)
[matthijs/upstream/backupninja.git] / src / backupninja.in
index ca5074c959ef93e7f375600a36bb9618ff30b657..f871e0c03e326fe832398dcfbc813a104564533b 100755 (executable)
@@ -1,5 +1,6 @@
 #!@BASH@
 # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*-
+# vim: set filetype=sh sw=3 sts=3 expandtab autoindent:
 #
 #                          |\_
 # B A C K U P N I N J A   /()/
@@ -142,14 +143,14 @@ function check_perms() {
    local perms
    local owners
 
-   perms=($(stat -L --format='%A' $file))
+   perms=($(@STAT@ -L --format='%A' $file))
    debug "perms: $perms"
    local gperm=${perms:4:3}
    debug "gperm: $gperm"
    local wperm=${perms:7:3}
    debug "wperm: $wperm"
 
-   owners=($(stat -L --format='%g %G %u %U' $file))
+   owners=($(@STAT@ -L --format='%g %G %u %U' $file))
    local gid=${owners[0]}
    local group=${owners[1]}
    local owner=${owners[2]}
@@ -334,8 +335,9 @@ function process_action() {
    _errors=`cat $bufferfile | grep "^Error: " | wc -l`
    _fatals=`cat $bufferfile | grep "^Fatal: " | wc -l`
    _halts=`cat $bufferfile | grep "^Halt: " | wc -l`
+   _infos=`cat $bufferfile | grep "^Info: " | wc -l`
 
-   ret=`grep "\(^Warning: \|^Error: \|^Fatal: \|Halt: \)" $bufferfile`
+   ret=`grep "\(^Info: \|^Warning: \|^Error: \|^Fatal: \|Halt: \)" $bufferfile`
    rm $bufferfile
    if [ $_halts != 0 ]; then
       msg "*halt* -- $file"
@@ -355,6 +357,9 @@ function process_action() {
       warning "<<<< finished action $file: WARNING"
    else
       msg "success -- $file"
+      if [ $_infos != 0 -a "$reportinfo" == "yes" ]; then
+         errormsg="$errormsg\n== infos from $file ==\n\n$ret\n"
+      fi
       info "<<<< finished action $file: SUCCESS"
    fi
 
@@ -455,6 +460,7 @@ getconf reportemail
 getconf reporthost
 getconf reportspace
 getconf reportsuccess yes
+getconf reportinfo no
 getconf reportuser
 getconf reportwarning yes
 getconf loglevel 3