aboutsummaryrefslogtreecommitdiff
path: root/network/arpwatch/rc.arpwatch
diff options
context:
space:
mode:
Diffstat (limited to 'network/arpwatch/rc.arpwatch')
-rw-r--r--network/arpwatch/rc.arpwatch63
1 files changed, 63 insertions, 0 deletions
diff --git a/network/arpwatch/rc.arpwatch b/network/arpwatch/rc.arpwatch
new file mode 100644
index 000000000000..9bf52da1d36b
--- /dev/null
+++ b/network/arpwatch/rc.arpwatch
@@ -0,0 +1,63 @@
+#!/bin/sh
+#
+# /etc/rc.d/rc./arpwatch
+#
+# Start/stop/restart/status arpwatch.
+
+ARPDIR="/var/lib/arpwatch"
+IFACE="$2"
+
+OPTIONS="-i $IFACE -f $ARPDIR/arp-$IFACE.dat -u root -e root -s root"
+
+pid="$(ps ax | awk '{if (match($5, ".*/arpwatch$") || $5 == "arpwatch") print $1}')"
+
+start() {
+ if [ "$IFACE" = "" ]; then
+ echo "Please specify interface name"
+ exit 1
+ else
+ if [ ! -f "$ARPDIR/arp-$IFACE.dat" ]; then
+ echo "Creating new database file..."
+ touch $ARPDIR/arp-$IFACE.dat
+ echo "Starting arpwatch on $IFACE..."
+ arpwatch $OPTIONS
+ else
+ echo "Starting arpwatch on $IFACE..."
+ arpwatch $OPTIONS
+ fi
+ fi
+}
+
+stop() {
+ echo "Stopping arpwatch..."
+ killall arpwatch
+}
+
+status() {
+ if [ "$pid" != "" ]; then
+ echo "arpwatch (pid "$pid") is running..."
+ else
+ echo "arpwatch is not running..."
+ fi
+}
+
+case "$1" in
+'start')
+ start
+ ;;
+'stop')
+ stop
+ ;;
+'restart')
+ stop
+ start
+ ;;
+'status')
+ status
+ ;;
+*)
+ echo ""
+ echo "Usage: $0 {start [IFACE] | stop | restart [IFACE] | status}"
+ echo ""
+ exit 1
+esac