"John R. Jackson" wrote:
>
> >... I hacked the script a bit to send mail *or* send to stdout (by
> >means of a -m switch, the same way amcheck does).
>
> That's probably a good idea.
>
> Could you post the change again but use a context (-c) or unified
> (-u) diff? Plain diff cannot be applied with "patch".
>
> Any chance I can let you to update the man page and write the ChangeLog
> entry? :-)
I added the patches (one for each file), supplied by 'diff -Naur'.
All it does is *not* sending the report file if no -m switch is given
(the file is created, though), or use an empty 'echo' function in case
of a -m switch. I'm not sure if this is *the* way to do it, but it
works...
Arjan
--- /opt/amanda/sbin/amverify Fri Jun 8 16:14:59 2001
+++ /var/amanda/bin/amverify Tue Jun 19 09:09:05 2001
@@ -23,6 +23,15 @@
SUF=
fi
+# First determine if we should run in mail mode: nothing is printed, but
+# a report is send by mail.
+if [ X"$1" == X"-m" ]; then
+ MAILMODE="yes"
+ shift
+else
+ MAILMODE="no"
+fi
+
# If the shell/system echo support \r and \c, use them to write some
# status messages over the top of each other as things progress, otherwise
# use a normal echo and let them go on new lines. Define $Echoe to be
@@ -29,34 +38,45 @@
# an echo that goes to stderr. In the code, $Echoe is used and it may
# be either echoe or echone, the latter being code that knows about echon.
-t=`echo "abc\r\c" | wc -c`
-if [ $t -eq 4 ]; then
- Echon=echon
+if [ X"$MAILMODE" = X"yes" ]; then
+ Echon=noecho
+ Echoe=noecho
+
+ noecho () {
+ # Placeholder
+ test "a" = "a"
+ }
else
- Echon=echo
-fi
-Echoe=echoe
-elen=0
-echoe() {
- echo "$@" >&2
- Echoe=echoe
-}
-echon() {
- newelen=`expr "$1" : '.*'`
- blanks=
- while [ $newelen -lt $elen ]; do
- blanks="$blanks "
- elen=`expr $elen - 1`
- done
- echo "$1""$blanks\r\c"
- elen=$newelen
- Echoe=echone
-}
-echone() {
- echon
- echoe "$@"
+ t=`echo "abc\r\c" | wc -c`
+ if [ $t -eq 4 ]; then
+ Echon=echon
+ else
+ Echon=echo
+ fi
Echoe=echoe
-}
+ elen=0
+
+ echoe() {
+ echo "$@" >&2
+ Echoe=echoe
+ }
+ echon() {
+ newelen=`expr "$1" : '.*'`
+ blanks=
+ while [ $newelen -lt $elen ]; do
+ blanks="$blanks "
+ elen=`expr $elen - 1`
+ done
+ echo "$1""$blanks\r\c"
+ elen=$newelen
+ Echoe=echone
+ }
+ echone() {
+ echon
+ echoe "$@"
+ Echoe=echoe
+ }
+fi
report() {
$Echoe "$@"
@@ -68,7 +88,7 @@
}
sendreport() {
- if [ -f $REPORT -a X"$REPORTTO" != X"" ]; then
+ if [ -f $REPORT -a X"$MAILMODE" = X"yes" -a X"$REPORTTO" != X"" ]; then
(
echo "Tapes: $TAPELIST"
if [ -s $DEFECTS ]; then
@@ -159,6 +179,7 @@
fi
fi
if [ X"$CMD" != X"" ]; then
+ report "Found: `basename $CMD` archive, verifying..."
if [ -x $CMD ]; then
$CMD $ARGS > /dev/null 2> $TEMP/errors
result=$?
@@ -249,7 +270,7 @@
SLOT=0
CONFIG=$1
[ X"$CONFIG" = X"" ] \
- && $Echoe "usage: amverify$SUF <config> [slot]" \
+ && $Echoe "usage: amverify$SUF [-m] <config> [slot]" \
&& exit 1
AMCONFIG=$CONFIG_DIR/$CONFIG/amanda.conf
--- amverify.8.in.orig Mon Jun 18 09:03:52 2001
+++ amverify.8.in Mon Jun 18 09:11:42 2001
@@ -12,6 +12,9 @@
amverify \- check an Amanda tape for errors
.SH SYNOPSIS
.B amverify
+[
+.I -m
+]
.I config
[
.I slot
@@ -59,6 +62,17 @@
See the
.IR amanda (8)
man page for more details about Amanda.
+.SH OPTIONS
+.TP
+.B \-m
+Nothing is printed, but a report is sent by mail.
+The mail goes to the
+.B mailto
+address specified in the
+.I amanda.conf
+file. If no
+.B mailto
+address is specied, no mail is sent.
.SH AUTHOR
Axel Zinser <[EMAIL PROTECTED]>
.SH "SEE ALSO"
--- ChangeLog.orig Mon Jun 25 11:47:27 2001
+++ ChangeLog Mon Jun 25 11:47:06 2001
@@ -1,3 +1,8 @@
+2001-06-25 Arjan J. Molenaar <[EMAIL PROTECTED]>
+
+ * server-src/amverify.sh.in: Added -m switch, for mail
+ * man/amverify.8.in: Added -m switch.
+
2001-04-13 John R. Jackson <[EMAIL PROTECTED]>
* example/amanda.conf.in: Fix multiple holding disks comment.