summaryrefslogtreecommitdiff
path: root/network/niceshaper/rc.niceshaper
diff options
context:
space:
mode:
authorMichal Bialozor <bialyy@o2.pl>2013-07-12 13:09:45 -0500
committerErik Hanson <erik@slackbuilds.org>2013-07-12 13:09:45 -0500
commit56954fb021d20377159f85f0b0ecac324c190008 (patch)
treea569f3517c639b7aeafa93fb4072eebdab6c1719 /network/niceshaper/rc.niceshaper
parentc3a19bf016bc447ee37fdafd8728d43945bfa6b9 (diff)
downloadslackbuilds-56954fb021d20377159f85f0b0ecac324c190008.tar.gz
network/niceshaper: Added (dynamic traffic shaper)
Signed-off-by: Erik Hanson <erik@slackbuilds.org>
Diffstat (limited to 'network/niceshaper/rc.niceshaper')
-rw-r--r--network/niceshaper/rc.niceshaper89
1 files changed, 89 insertions, 0 deletions
diff --git a/network/niceshaper/rc.niceshaper b/network/niceshaper/rc.niceshaper
new file mode 100644
index 0000000000..3296e2690e
--- /dev/null
+++ b/network/niceshaper/rc.niceshaper
@@ -0,0 +1,89 @@
+#!/bin/sh
+#
+# Startup script for NiceShaper - Dynamic Traffic Shaper
+#
+# Usage: ./rc.niceshaper {start|stop|restart|status}
+
+PRGNAM=niceshaper
+PRGDIR=/usr/sbin/
+PIDDIR=/var/run/
+RETVAL=0
+
+prg_start() {
+ echo -n "Starting $PRGNAM ... "
+ if [ -r ${PIDDIR}${PRGNAM}.pid ]; then
+ if $(! /sbin/pidof $PRGNAM > /dev/null 2>&1 ) ; then
+ echo -n "removing an old ${PIDDIR}${PRGNAM}.pid ... "
+ rm -f ${PIDDIR}${PRGNAM}.pid
+ fi
+ fi
+ ${PRGDIR}${PRGNAM} start > /dev/null 2>&1
+ RETVAL=$?
+
+ if [ $RETVAL -eq 0 ]; then
+ touch /var/lock/$PRGNAM
+ sleep 2
+ echo "done"
+ else
+ echo "failed"
+ fi
+ return $RETVAL
+}
+
+prg_stop() {
+ echo -n "Stopping $PRGNAM ... "
+ if [ -r ${PIDDIR}${PRGNAM}.pid ]; then
+ ${PRGDIR}${PRGNAM} stop > /dev/null 2>&1
+ # Give it some time to die gracefully
+ for second in 0 1 2 3 4 5 6 7 8 9 10 ; do
+ if $(! /sbin/pidof $PRGNAM > /dev/null 2>&1 ) ; then
+ rm -f ${PIDDIR}${PRGNAM}.pid
+ break;
+ fi
+ sleep 1
+ done
+
+ if [ "$second" = "10" ]; then
+ echo "\nWARNING: $PRGNAM did not exit!"
+ sleep 10
+ else
+ echo "done"
+ fi
+ fi
+ rm -f /var/lock/$PRGNAM
+ return $RETVAL
+}
+
+prg_status() {
+ if [ -e ${PIDDIR}${PRGNAM}.pid ]; then
+ echo "$PRGNAM (pid $(cat ${PIDDIR}${PRGNAM}.pid)) is running..."
+ else
+ echo "$PRGNAM is stopped..."
+ RETVAL=1
+ fi
+}
+
+# How were we called:
+case "$1" in
+ start)
+ prg_start
+ ;;
+ stop)
+ prg_stop
+ ;;
+ restart|reload)
+ prg_stop
+ # Wait a few seconds before restarting
+ sleep 1
+ prg_start
+ ;;
+ status)
+ prg_status
+ ;;
+ *)
+ echo "Usage: $(basename $0) {start|stop|restart|status}"
+ RETVAL=1
+esac
+
+exit $RETVAL
+# EOF