freebsd-ports/net/arpwatch/files/arpwatch.sh
Neil Blakey-Milner fe5a0493bd arpwatch package will now install an arp.dat file, meaning arpwatch from
the package will work by default.

Additionally, setting arpwatch_interfaces in the rc.conf system will
allow you to specify which interfaces arpwatches will run on.  By
default (ie, variable empty or not set), it will run on the first
non-local interface it finds.

Approved by:	brian (thanks!)
2001-08-23 14:45:02 +00:00

53 lines
992 B
Bash

#!/bin/sh
if [ -r /etc/defaults/rc.conf ]; then
. /etc/defaults/rc.conf
source_rc_confs
elif [ -r /etc/rc.conf ]; then
. /etc/rc.conf
fi
prog=$(realpath $0) || exit 1
dir=${prog%/*}
PREFIX=${dir%/etc/rc.d}
if [ ."$dir" = ."$prog" -o ."$PREFIX" = ."$dir" ]
then
echo "$0: Cannot determine the PREFIX" >&2
exit 1
fi
case $1 in
start)
if [ ! -e "$PREFIX"/arpwatch/arp.dat ]; then
if [ -e "$PREFIX"/arpwatch/arp.dat- ]; then
cp "$PREFIX"/arpwatch/arp.dat- "$PREFIX"/arpwatch/arp.dat
else
touch "$PREFIX"/arpwarch/arp.dat
fi
fi
case ${arpwatch_interfaces} in
'')
if [ -x "$PREFIX"/sbin/arpwatch -a -d "$PREFIX"/arpwatch ]; then
"$PREFIX"/sbin/arpwatch && echo -n ' arpwatch'
fi
;;
*)
for interface in ${arpwatch_interfaces}; do
"$PREFIX"/sbin/arpwatch -i "${interface}" && echo -n " arpwatch(${interface})"
done
;;
esac
;;
stop)
killall arpwatch && echo -n ' arpwatch'
;;
*)
echo "Usage: `basename $0` {start|stop}" >&2
exit 64
;;
esac
exit 0