aboutsummaryrefslogtreecommitdiffstats
path: root/net-mgmt/trafd
diff options
context:
space:
mode:
authorbms <bms@FreeBSD.org>2003-12-12 09:09:38 +0800
committerbms <bms@FreeBSD.org>2003-12-12 09:09:38 +0800
commit45538736da216a134c96ab0c864d12a67df2efbf (patch)
tree4cf32173000d9b8201145ab89593dd163b4c52bf /net-mgmt/trafd
parentbd8b027717301062af6fa0c606f38f336ca29288 (diff)
downloadfreebsd-ports-gnome-45538736da216a134c96ab0c864d12a67df2efbf.tar.gz
freebsd-ports-gnome-45538736da216a134c96ab0c864d12a67df2efbf.tar.zst
freebsd-ports-gnome-45538736da216a134c96ab0c864d12a67df2efbf.zip
Whoops. Add the rcNG script itself.
Diffstat (limited to 'net-mgmt/trafd')
-rw-r--r--net-mgmt/trafd/files/trafd.sh.sample54
1 files changed, 54 insertions, 0 deletions
diff --git a/net-mgmt/trafd/files/trafd.sh.sample b/net-mgmt/trafd/files/trafd.sh.sample
new file mode 100644
index 000000000000..daf53e8c4b1b
--- /dev/null
+++ b/net-mgmt/trafd/files/trafd.sh.sample
@@ -0,0 +1,54 @@
+#!/bin/sh
+#
+
+# PROVIDE: trafd
+# REQUIRE: netif routing
+# KEYWORD: FreeBSD shutdown
+
+#
+# Add the following lines to /etc/rc.conf to enable trafd:
+#
+#trafd_enable="YES"
+#trafd_ifaces="fxp0 fxp1 fxp2"
+#trafd_flags=""
+#trafd_log="/var/log/traffic.log"
+#
+
+. %%RC_SUBR%%
+
+name="trafd"
+rcvar=`set_rcvar`
+command="/usr/local/bin/trafd"
+start_cmd="trafd_start"
+stop_cmd="trafd_stop"
+
+trafd_enable=${trafd_enable:-"NO"}
+trafd_log=${trafd_log:-"/var/log/traffic.log"}
+load_rc_config $name
+
+trafd_start()
+{
+ echo 'Starting trafd.'
+ if checkyesno ${rcvar} && [ "x${trafd_ifaces}" != "x" ]; then
+ for iface in ${trafd_ifaces}; do
+ ${command} -i ${iface} ${trafd_flags}
+ done
+ else
+ warn '$trafd_ifaces is not set.'
+ fi
+}
+
+trafd_stop()
+{
+ echo 'Stopping trafd.'
+ for iface in ${trafd_ifaces}; do
+ read rc_pid < /var/run/trafd.$iface
+ if [ -n "${rc_pid}" ]; then
+ kill -TERM ${rc_pid}
+ wait_for_pids ${rc_pid}
+ echo "$(date +"%b %e %H:%M:%S") $(hostname -s) trafstop:" "'('${iface}')' signaling to shutdown" >> ${trafd_log}
+ fi
+ done
+}
+
+run_rc_command "$1"