X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=server-src%2Famdump.sh.in;h=25471a5e599360cc0669d1185925ae613bc1da4e;hb=d3b2175e084f88c8736ad7073eacbf4670147aec;hp=ce56b8f164c3c7f8ceac0d2d9544a005f569af8c;hpb=3ab887b9bc819a846c75dd7f2ee5d41fac22b19f;p=debian%2Famanda diff --git a/server-src/amdump.sh.in b/server-src/amdump.sh.in index ce56b8f..25471a5 100644 --- a/server-src/amdump.sh.in +++ b/server-src/amdump.sh.in @@ -1,4 +1,4 @@ -#!/bin/sh +#!@SHELL@ # # Amanda, The Advanced Maryland Automatic Network Disk Archiver # Copyright (c) 1991-1998 University of Maryland at College Park @@ -47,20 +47,29 @@ else SUF= fi +if [ $# -lt 1 ] +then + echo "Usage: amdump config [host [disk...]...]" 1>&2 + exit 1 +fi + +exit_status=0; + conf=$1 if [ ! -d $confdir/$conf ]; then - echo "amdump$SUF: could not find directory $confdir/$conf" + echo "amdump$SUF: could not find directory $confdir/$conf" 1>&2 exit 1 fi +shift cd $confdir/$conf || exit 1 -logdir=`amgetconf$SUF $conf logdir` +logdir=`amgetconf$SUF $conf logdir "$@"` [ $? -ne 0 ] && exit 1 errfile=$logdir/amdump -tapecycle=`amgetconf$SUF $conf tapecycle` +tapecycle=`amgetconf$SUF $conf tapecycle "$@"` [ $? -ne 0 ] && exit 1 -dumpuser=`amgetconf$SUF $conf dumpuser` +dumpuser=`amgetconf$SUF $conf dumpuser "$@"` [ $? -ne 0 ] && exit 1 runuser=`{ whoami ; } 2>/dev/null` @@ -73,38 +82,61 @@ if [ $? -ne 0 ]; then fi fi -if [ $runuser != $dumpuser ]; then - echo "amdump: must be run as user $dumpuser, not $runuser" - exit 1 -fi +#if [ $runuser != $dumpuser ]; then +# echo "amdump: must be run as user $dumpuser, not $runuser" 1>&2 +# exit 1 +#fi if test -f hold; then - echo "amdump: waiting for hold file to be removed" >&2 + echo "amdump: waiting for hold file to be removed" 1>&2 while test -f hold; do sleep 60 done fi if test -f $errfile || test -f $logdir/log; then - echo "amdump: amdump or amflush is already running, or you must run amcleanup" >&2 + echo "amdump: amdump or amflush is already running, or you must run amcleanup" 1>&2 exit 1 fi umask 077 +exit_code=0 # Plan and drive the dumps. -exec $errfile 2>&1 +#exec $errfile 2>&1 +touch $errfile +exit_code=$? +[ $exit_code -ne 0 ] && exit_status=$exit_code +exec >$errfile 1>&2 +exit_code=$? +[ $exit_code -ne 0 ] && exit_status=$exit_code echo "amdump: start at `date`" echo "amdump: datestamp `date +%Y%m%d`" -$libexecdir/planner$SUF "$@" | $libexecdir/driver$SUF $conf +echo "amdump: starttime `date +%Y%m%d%H%M%S`" +$libexecdir/planner$SUF $conf "$@" | $libexecdir/driver$SUF $conf "$@" +exit_code=$? +[ $exit_code -ne 0 ] && exit_status=$exit_code echo "amdump: end at `date`" # Send out a report on the dumps. -exec /dev/null 2>&1 -$sbindir/amreport$SUF $conf +$sbindir/amreport$SUF $conf "$@" +exit_code=$? +[ $exit_code -ne 0 ] && exit_status=$exit_code # Roll the log file to its datestamped name. -$libexecdir/amlogroll$SUF $conf +$libexecdir/amlogroll$SUF $conf "$@" +exit_code=$? +[ $exit_code -ne 0 ] && exit_status=$exit_code + +# Trim the log file to those for dumps that still exist. +$libexecdir/amtrmlog$SUF $conf "$@" +exit_code=$? +[ $exit_code -ne 0 ] && exit_status=$exit_code + +# Trim the index file to those for dumps that still exist. +$libexecdir/amtrmidx$SUF $conf "$@" +exit_code=$? +[ $exit_code -ne 0 ] && exit_status=$exit_code # Keep a debug log through the tapecycle plus a couple of days. maxdays=`expr $tapecycle + 2` @@ -118,14 +150,13 @@ done while [ $days -ge 2 ]; do ndays=`expr $days - 1` mv $errfile.$ndays $errfile.$days + exit_code=$? + echo $exit_code + [ $exit_code -ne 0 ] && exit_status=$exit_code days=$ndays done mv $errfile $errfile.1 +exit_code=$? +[ $exit_code -ne 0 ] && exit_status=$exit_code -# Trim the log file to those for dumps that still exist. -$libexecdir/amtrmlog$SUF $conf - -# Trim the index file to those for dumps that still exist. -$libexecdir/amtrmidx$SUF $conf - -exit 0 +exit $exit_status