diff options
author | root <root@rshg054.dnsready.net> | 2012-05-19 00:02:33 +0000 |
---|---|---|
committer | root <root@rshg054.dnsready.net> | 2012-05-19 00:02:33 +0000 |
commit | 5d334c7470b5851fbacd4545c8ee0ea676a21ccc (patch) | |
tree | 9fd6a98989a409178f5db098aaf2ffa8a646dd48 /community/iperf/iperf.rc | |
parent | 2f104ecf78d6a93ba8d67273b76364cb1365a6cf (diff) |
Sat May 19 00:02:33 UTC 2012
Diffstat (limited to 'community/iperf/iperf.rc')
-rw-r--r-- | community/iperf/iperf.rc | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/community/iperf/iperf.rc b/community/iperf/iperf.rc new file mode 100644 index 000000000..617b666ad --- /dev/null +++ b/community/iperf/iperf.rc @@ -0,0 +1,52 @@ +#!/bin/bash + +# You can use this script to run iperf as tcp and udp. +# Copy and rename this script to /etc/rc.d/iperf-udp and copy config file to +# /etc/conf.d/iperf-udp and add -u to daemon options + +. /etc/rc.conf +. /etc/rc.d/functions +[[ -r /etc/conf.d/${0##*/} ]] && . /etc/conf.d/${0##*/} + +DAEMON=${DAEMON:-/usr/bin/iperf} +PIDFILE=${PIDFILE:-/run/${0##*/}.pid} +DAEMON_OPTS="--server $DAEMON_OPTS" + +# check pid +[[ -r "$PIDFILE" ]] && + read PID < "$PIDFILE" && [[ -n $PID ]] && kill -0 $PID &>/dev/null || unset PID + +case "$1" in + start) + stat_busy "Starting ${0##*/} daemon" + [[ -z $PID ]] && + { $DAEMON $DAEMON_OPTS </dev/null &>/dev/null & } && + echo "$!" > "$PIDFILE" && + disown %% && + add_daemon ${0##*/} && + stat_done && + exit 0 + stat_fail + ;; + stop) + stat_busy "Stopping ${0##*/} daemon" + [[ -n $PID ]] && kill $PID &> /dev/null && + rm_daemon ${0##*/} && + rm -f "$PIDFILE" && + stat_done && + exit 0 + stat_fail + ;; + restart) + $0 stop + $0 start + exit 0 + ;; + *) + echo "usage: ${0##*/} {start|stop|restart}" >&2 + ;; +esac + +exit 1 + +# vim:set ts=2 sw=2 ft=sh noet: |