3 # Amanda, The Advanced Maryland Automatic Network Disk Archiver
4 # Copyright (c) 1991-1998 University of Maryland at College Park
7 # Permission to use, copy, modify, distribute, and sell this software and its
8 # documentation for any purpose is hereby granted without fee, provided that
9 # the above copyright notice appear in all copies and that both that
10 # copyright notice and this permission notice appear in supporting
11 # documentation, and that the name of U.M. not be used in advertising or
12 # publicity pertaining to distribution of the software without specific,
13 # written prior permission. U.M. makes no representations about the
14 # suitability of this software for any purpose. It is provided "as is"
15 # without express or implied warranty.
17 # U.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
18 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL U.M.
19 # BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
20 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
21 # OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
22 # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
24 # Author: James da Silva, Systems Design and Analysis Group
25 # Computer Science Department
26 # University of Maryland at College Park
30 # amcleanup.sh - clean up and generate a report after a crash.
32 # try to hit all the possibilities here
34 exec_prefix=@exec_prefix@
35 libexecdir=@libexecdir@
40 PATH=$sbindir:$libexecdir:/usr/bin:/bin:/usr/sbin:/sbin:/usr/ucb
43 USE_VERSION_SUFFIXES="@USE_VERSION_SUFFIXES@"
44 if test "$USE_VERSION_SUFFIXES" = yes; then
52 echo "Usage: amcleanup conf"
57 if [ ! -d $confdir/$conf ]; then
58 echo "amcleanup: could not cd into $confdir/$conf"
64 logdir=`amgetconf$SUF logdir`
65 [ $? -ne 0 ] && exit 1
67 errfile=$logdir/amdump
68 erramflush=$logdir/amflush
69 tapecycle=`amgetconf$SUF tapecycle`
71 if [ -f $logfile ]; then
74 echo "amcleanup: processing outstanding log file."
75 exec </dev/null >/dev/null 2>&1
78 # Roll the log file to its datestamped name.
81 # Trim the index file to those for dumps that still exist.
85 echo "amcleanup: no unprocessed logfile to clean up."
90 if [ -f $errfile ]; then
91 # if log was found, this will have been directed to /dev/null,
93 echo "amcleanup: $errfile exists, renaming it."
95 # Keep debug log through the tapecycle plus a couple days
96 maxdays=`expr $tapecycle + 2`
99 # First, find out the last existing errfile,
100 # to avoid ``infinite'' loops if tapecycle is infinite
101 while [ $days -lt $maxdays ] && [ -f $errfile.$days ]; do
102 days=`expr $days + 1`
104 # Now, renumber the existing log files
105 while [ $days -ge 2 ]; do
106 ndays=`expr $days - 1`
107 mv $errfile.$ndays $errfile.$days
110 mv $errfile $errfile.1
113 if [ -f $erramflush ]; then
114 # if log was found, this will have been directed to /dev/null,
116 echo "amcleanup: $erramflush exists, renaming it."
118 # Keep debug log through the tapecycle plus a couple days
119 maxdays=`expr $tapecycle + 2`
122 # First, find out the last existing erramflush,
123 # to avoid ``infinite'' loops if tapecycle is infinite
124 while [ $days -lt $maxdays ] && [ -f $erramflush.$days ]; do
125 days=`expr $days + 1`
127 # Now, renumber the existing log files
128 while [ $days -ge 2 ]; do
129 ndays=`expr $days - 1`
130 mv $erramflush.$ndays $erramflush.$days
133 mv $erramflush $erramflush.1
136 $libexecdir/amcleanupdisk $conf