From 4ecaae94054c4eb919ddbd45904d834383a09558 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Fri, 22 May 2009 14:50:52 +0200 Subject: Make all indentation consistent. Previously, there were many indentation styles in use: Real tabs, 2, 3 or 4 spaces, mixing these within the same file, function or even within a single line. This commit changes all bash scripts in the handlers, src and lib dirs to use consistent indentation: three spaces are now used everywhere. Other files (e.g. Makefiles) are left untouched. Additionally, this commit removes all trailing whitespace. --- src/ninjareport.in | 163 ++++++++++++++++++++++++++--------------------------- 1 file changed, 81 insertions(+), 82 deletions(-) (limited to 'src/ninjareport.in') diff --git a/src/ninjareport.in b/src/ninjareport.in index b68efb8..56a7209 100755 --- a/src/ninjareport.in +++ b/src/ninjareport.in @@ -13,7 +13,7 @@ # . check for logs that are never updating and warn # . change constantly updating logs (maildir) to be more friendly # . documentation -# . maybe make config option that lists all hosts that should report-in, and if +# . maybe make config option that lists all hosts that should report-in, and if # one doesn't then warn # . restrict rsync somehow? # . abstract path for logtail @@ -29,7 +29,7 @@ process() { # # note: some backups never finish, such as the maildir one, need to handle these # perhaps by looking for FAILED messages? -# note2: what about logs that aren't being updated? this is a failure case and +# note2: what about logs that aren't being updated? this is a failure case and # should be looked for # note3: there are also these entries: # Jan 20 14:00:01 Fatal: No backup actions configured in '/etc/backup.d', run ninjahelper! @@ -38,27 +38,27 @@ process() { logupdates=`maketemp ninjadata` /usr/sbin/logtail -f $host > $logupdates -grep FINISHED $logupdates | +grep FINISHED $logupdates | ( - fatal=0 - warning=0 - error=0 - - while read line - do - line_array=($line) - fatal=$(($fatal + ${line_array[8]})) - error=$(($error + ${line_array[10]})) - warning=$(($warning + ${line_array[12]})) - done - if (( $fatal || $warning || $error )); then - echo "`basename $host .log`: $fatal fatals found, $error errors found, $warning warnings found" >> $statusfile - echo "" >> $reportappend - echo "`basename $host .log` log entries since last ninjareport" >> $reportappend - echo "---------" >> $reportappend - cat $logupdates >> $reportappend - rm $logupdates - fi + fatal=0 + warning=0 + error=0 + + while read line + do + line_array=($line) + fatal=$(($fatal + ${line_array[8]})) + error=$(($error + ${line_array[10]})) + warning=$(($warning + ${line_array[12]})) + done + if (( $fatal || $warning || $error )); then + echo "`basename $host .log`: $fatal fatals found, $error errors found, $warning warnings found" >> $statusfile + echo "" >> $reportappend + echo "`basename $host .log` log entries since last ninjareport" >> $reportappend + echo "---------" >> $reportappend + cat $logupdates >> $reportappend + rm $logupdates + fi ) } @@ -69,31 +69,31 @@ reportfile=`maketemp ninjareport` # Generate a report, only if there are failures if [ -s $statusfile ]; then - echo " backupninja mission failures - `date`" >> $reportfile - echo " --------------------------------------------------------------" >> $reportfile - echo "" >> $reportfile - cat $statusfile | column -t >> $reportfile - echo "" >> $reportfile - echo " log entries from failed reports" >> $reportfile - echo " -----------------------------------" >> $reportfile - cat $reportappend >> $reportfile + echo " backupninja mission failures - `date`" >> $reportfile + echo " --------------------------------------------------------------" >> $reportfile + echo "" >> $reportfile + cat $statusfile | column -t >> $reportfile + echo "" >> $reportfile + echo " log entries from failed reports" >> $reportfile + echo " -----------------------------------" >> $reportfile + cat $reportappend >> $reportfile fi } usage() { - cat << EOF + cat << EOF This script generates a backupninja status report for all configured systems. It requires that each status report is placed in a spot where ninjareport can read it, reports are mailed to the reportemail configured in @CFGDIR@/backupninja.conf. The following options are available: --h, --help This usage message --f, --conffile FILE Use FILE for the configuration instead - of @CFGDIR@/backupninja.conf --m, --mail Mail the report to this address --o, --out Don't mail the report, just display it +-h, --help This usage message +-f, --conffile FILE Use FILE for the configuration instead + of @CFGDIR@/backupninja.conf +-m, --mail Mail the report to this address +-o, --out Don't mail the report, just display it EOF } @@ -106,45 +106,45 @@ conffile="@CFGDIR@/backupninja.conf" ## process command line options while [ $# -ge 1 ]; do - case $1 in - -h|--help) - usage - exit 0 - ;; - -f|--conffile) - if [ -f $2 ]; then - conffile=$2 - else - echo "-f|--conffile option must be followed by an existing filename" - fatal "-f|--conffile option must be followed by an existing filename" - usage - fi - # we shift here to avoid processing the file path - shift - ;; - -m|--mail) - reportemail=$2 - shift - ;; - -o|--out) - mail=0 - display=1 - ;; - *) - echo "Unknown option $1" - usage - exit - ;; - esac - shift -done + case $1 in + -h|--help) + usage + exit 0 + ;; + -f|--conffile) + if [ -f $2 ]; then + conffile=$2 + else + echo "-f|--conffile option must be followed by an existing filename" + fatal "-f|--conffile option must be followed by an existing filename" + usage + fi + # we shift here to avoid processing the file path + shift + ;; + -m|--mail) + reportemail=$2 + shift + ;; + -o|--out) + mail=0 + display=1 + ;; + *) + echo "Unknown option $1" + usage + exit + ;; + esac + shift +done ## Load and confirm basic configuration values # bootstrap if [ ! -r "$conffile" ]; then - echo "Configuration file $conffile not found." - fatal "Configuration file $conffile not found." + echo "Configuration file $conffile not found." + fatal "Configuration file $conffile not found." fi # find $libdirectory @@ -153,12 +153,12 @@ 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 @@ -176,17 +176,17 @@ getconf reportemail hosts=`find $reportdirectory -follow -mindepth 1 -maxdepth 1 -type f ! -name '*.offset' | sort -n` if [ -z "$hosts" ]; then - echo "Fatal: No backupninja reports found in '$reportdirectory'!" - mail=0 + echo "Fatal: No backupninja reports found in '$reportdirectory'!" + mail=0 fi statusfile=`maketemp ninjastatus` reportappend=`maketemp ninjaappend` for host in $hosts; do - [ -f "$host" ] || continue - # Check somehow that the file is a valid report file - process $host + [ -f "$host" ] || continue + # Check somehow that the file is a valid report file + process $host done generatereport @@ -194,12 +194,11 @@ generatereport ## mail the report to the report address or display it if [ -s $reportfile ]; then - if [ $mail == 1 ]; then - mail -s "backupninja mission failure report" $reportemail < $reportfile - fi + if [ $mail == 1 ]; then + mail -s "backupninja mission failure report" $reportemail < $reportfile + fi fi if [ $display == 1 ]; then - cat $reportfile + cat $reportfile fi - -- cgit v1.2.3 From 78884142e7cdaaf3e1f5571b1f28d2ea5a520b30 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Fri, 22 May 2009 15:27:09 +0200 Subject: Add a vim modeline with indentation settings. The modelines added match the emacs lines already present and also set the filetype to sh (just like the emacs lines). --- handlers/dup.helper.in | 1 + handlers/dup.in | 1 + handlers/ldap.helper.in | 1 + handlers/ldap.in | 1 + handlers/maildir.in | 1 + handlers/makecd.helper.in | 1 + handlers/makecd.in | 1 + handlers/mysql.helper.in | 1 + handlers/mysql.in | 1 + handlers/pgsql.helper.in | 1 + handlers/pgsql.in | 1 + handlers/rdiff.helper.in | 1 + handlers/rdiff.in | 1 + handlers/rsync.in | 2 ++ handlers/sh.in | 1 + handlers/svn.in | 1 + handlers/sys.helper.in | 1 + handlers/sys.in | 1 + handlers/tar.helper.in | 1 + handlers/tar.in | 1 + handlers/trac.in | 1 + handlers/wget | 2 ++ lib/easydialog.in | 1 + lib/tools.in | 1 + lib/vserver.in | 1 + src/backupninja.in | 1 + src/ninjahelper.in | 1 + src/ninjareport.in | 1 + 28 files changed, 30 insertions(+) (limited to 'src/ninjareport.in') diff --git a/handlers/dup.helper.in b/handlers/dup.helper.in index 86745c8..3c08a2f 100644 --- a/handlers/dup.helper.in +++ b/handlers/dup.helper.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: HELPERS="$HELPERS dup:incremental_encrypted_remote_filesystem_backup" diff --git a/handlers/dup.in b/handlers/dup.in index 60a4ce9..aed6030 100644 --- a/handlers/dup.in +++ b/handlers/dup.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: # # duplicity script for backupninja # requires duplicity diff --git a/handlers/ldap.helper.in b/handlers/ldap.helper.in index 4870ae4..4154cc6 100644 --- a/handlers/ldap.helper.in +++ b/handlers/ldap.helper.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: HELPERS="$HELPERS ldap:ldap_database_backup" diff --git a/handlers/ldap.in b/handlers/ldap.in index 0b0166e..5f402c7 100644 --- a/handlers/ldap.in +++ b/handlers/ldap.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: # # openldap backup handler script for backupninja # diff --git a/handlers/maildir.in b/handlers/maildir.in index e88619d..ab72ce1 100644 --- a/handlers/maildir.in +++ b/handlers/maildir.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: ############################################################### # diff --git a/handlers/makecd.helper.in b/handlers/makecd.helper.in index c8a6762..ad0c4aa 100644 --- a/handlers/makecd.helper.in +++ b/handlers/makecd.helper.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: HELPERS="$HELPERS makecd:makecd_backup" wizardname="makecd action wizard" diff --git a/handlers/makecd.in b/handlers/makecd.in index 78e5454..d44bba3 100644 --- a/handlers/makecd.in +++ b/handlers/makecd.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: # # burncd handler script for backupninja # diff --git a/handlers/mysql.helper.in b/handlers/mysql.helper.in index fb9f11d..997f73c 100644 --- a/handlers/mysql.helper.in +++ b/handlers/mysql.helper.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: HELPERS="$HELPERS mysql:mysql_database_backup" diff --git a/handlers/mysql.in b/handlers/mysql.in index a4a3667..88ffb1a 100644 --- a/handlers/mysql.in +++ b/handlers/mysql.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: # # mysql handler script for backupninja # diff --git a/handlers/pgsql.helper.in b/handlers/pgsql.helper.in index 48bf047..ff1cfd4 100644 --- a/handlers/pgsql.helper.in +++ b/handlers/pgsql.helper.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: HELPERS="$HELPERS pgsql:postgresql_database_backup" diff --git a/handlers/pgsql.in b/handlers/pgsql.in index b7e4262..ff5f7ba 100644 --- a/handlers/pgsql.in +++ b/handlers/pgsql.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: # # PostgreSQL handler script for backupninja # diff --git a/handlers/rdiff.helper.in b/handlers/rdiff.helper.in index c673723..83f2fb5 100644 --- a/handlers/rdiff.helper.in +++ b/handlers/rdiff.helper.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: HELPERS="$HELPERS rdiff:incremental_remote_filesystem_backup" diff --git a/handlers/rdiff.in b/handlers/rdiff.in index 51da1cc..f59d56a 100644 --- a/handlers/rdiff.in +++ b/handlers/rdiff.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: # # rdiff-backup handler script for backupninja # requires rdiff-backup diff --git a/handlers/rsync.in b/handlers/rsync.in index 9e5e4f9..072f2a6 100644 --- a/handlers/rsync.in +++ b/handlers/rsync.in @@ -1,3 +1,5 @@ +# -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: # # backupninja handler to do incremental backups using # rsync and hardlinks, based on diff --git a/handlers/sh.in b/handlers/sh.in index 4edfd9a..b070f3b 100644 --- a/handlers/sh.in +++ b/handlers/sh.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: # # shell script handler for backupninja # runs the file /etc/backup.d/scriptname.sh diff --git a/handlers/svn.in b/handlers/svn.in index 97d1701..5e5531a 100644 --- a/handlers/svn.in +++ b/handlers/svn.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: # # this handler will backup subversion repostitories. # diff --git a/handlers/sys.helper.in b/handlers/sys.helper.in index c823712..8a2fb07 100644 --- a/handlers/sys.helper.in +++ b/handlers/sys.helper.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: HELPERS="$HELPERS sys:general_hardware_and_system_info" diff --git a/handlers/sys.in b/handlers/sys.in index 2ab5871..69751ed 100755 --- a/handlers/sys.in +++ b/handlers/sys.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: # # this handler will save various reports of vital system information. # by default, all the reports are saved in /var/backups. diff --git a/handlers/tar.helper.in b/handlers/tar.helper.in index 2665382..cdbe03a 100644 --- a/handlers/tar.helper.in +++ b/handlers/tar.helper.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: HELPERS="$HELPERS tar:tar_backup" diff --git a/handlers/tar.in b/handlers/tar.in index 0a762ce..b4f8c58 100644 --- a/handlers/tar.in +++ b/handlers/tar.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: # # tar handler script for backupninja diff --git a/handlers/trac.in b/handlers/trac.in index f387d42..018bffd 100644 --- a/handlers/trac.in +++ b/handlers/trac.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: # # this handler will backup trac environments (based on the svn handler) # diff --git a/handlers/wget b/handlers/wget index 0c363eb..ebb391e 100644 --- a/handlers/wget +++ b/handlers/wget @@ -1,3 +1,5 @@ +# -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: # # backupninja handler to do incremental backups using # wget and hardlinks, based on rsync handler diff --git a/lib/easydialog.in b/lib/easydialog.in index a0495a7..c41e6f7 100644 --- a/lib/easydialog.in +++ b/lib/easydialog.in @@ -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: # copyright 2002 lmoore@tump.com under the terms of the GNU LGPL. # additions 2005 collective@riseup.net diff --git a/lib/tools.in b/lib/tools.in index 0d368b8..929826b 100644 --- a/lib/tools.in +++ b/lib/tools.in @@ -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: # This file contains functions shared between ninjahelper and backupninja. diff --git a/lib/vserver.in b/lib/vserver.in index cc96a71..b356b2b 100644 --- a/lib/vserver.in +++ b/lib/vserver.in @@ -1,4 +1,5 @@ # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: ##################################################### ## VSERVERS RELATED FUNCTIONS FOR NINJAHELPER diff --git a/src/backupninja.in b/src/backupninja.in index ca5074c..a158715 100755 --- a/src/backupninja.in +++ b/src/backupninja.in @@ -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 /()/ diff --git a/src/ninjahelper.in b/src/ninjahelper.in index 7bbef1f..2a7faa9 100755 --- a/src/ninjahelper.in +++ b/src/ninjahelper.in @@ -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: #################################################### ## Functions diff --git a/src/ninjareport.in b/src/ninjareport.in index 56a7209..4bc244e 100755 --- a/src/ninjareport.in +++ b/src/ninjareport.in @@ -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: # # # Ninjareport - generate a single simple report for a lot of hosts -- cgit v1.2.3