Iperf init

From PRAGMA wiki
Jump to: navigation, search

This is an example. Please adjust to fit your system.

#/bin/bash
# chkconfig: 345 99 99
# description: Starts the iperf Server
# processname: iperf

# Source function library.
. /etc/init.d/functions

test -x /opt/iperf/bin/iperf || exit 0

export IPERF=/opt/iperf/bin/iperf
export SERVER_OPTS="-sD"

start() {
        echo -n $"Starting iperf Server: "
        daemon $IPERF $SERVER_OPTS  2> /var/log/iperf &
        RETVAL=$?
        [ $RETVAL = 0 ] && touch /var/lock/subsys/iperf
        echo
        return $RETVAL
}

stop() {
        echo -n $"Shutting down iperf Server: "
        killproc $IPERF
        RETVAL=$?
        [ $RETVAL = 0 ] && rm -f /var/lock/subsys/iperf
        echo
        return $RETVAL

}

restart() {
        stop
        start
}

RETVAL=0
# See how we were called.
case "$1" in

  start)
        start
        ;;
  stop)
        stop
        ;;
  status)
        status $IPERF
        ;;
  restart|reload)
        restart
        ;;
**)
        echo $"Usage: $0 {start|stop|status|restart}"
        exit 1
esac
exit $?