#! /usr/local/bin/setuid -r
#? /bin/sh /u/dump/bin/slavedump
#
#  - Stuart Levy, Geometry Group, April 1989
#
# slavedump {0-9}[u] /filesystem-or-device
#
# Privileged shell script.  Dump(8)'s the specified filesystem to stdout.
# Only one filesystem is permitted.
#
# {0-9}	Dump level - a single digit in the range 0..9.  Required.
# u	Update the /etc/dumpdates file on the remote machine.
#
# No other dump options are accepted.
#

case "$1#$2#$3" in
    [0-9]#/*#|[0-9]u#/*#)
	;;
    *)
	echo >&2 \
"Usage:  $0  {0-9}[u]  /filesystem-or-device
Dump(8) specified filesystem to stdout.
Digit 0..9 is dump level, optional 'u' => update /etc/dumpdates on slave host."
	exit 1
	;;
esac

# Security check.  We should only be executed by uid "dump"!
# SETUID_REALUSER provided by a hack to /usr/local/bin/setuid.

case "$SETUID_REALUSER" in
    dump|root) ;;
    *) echo "$0 may only be invoked by user 'dump'.  Go away." >&2; exit 3 ;;
esac

CPU=`cat /etc/cputype`
PATH=/u/dump/etc.$CPU:/u/dump/bin:/usr/ucb:/bin:/usr/bin:/etc:/usr/etc

BLKS=`expr ${BSIZE:-64512} / 512`
TSIZE=145000
Q=
if [ -x /u/dump/etc/dump.$CPU ]; then
	Q=q
fi
dump ${1}${Q}fsb - ${TSIZE} ${BLKS}  $2
