#!/sbin/runscript start() { ebegin "Starting shaperd: " for c in `ls -1 /etc/shaper | grep "shaper\.[0123456789]\.cfg$" | cut -d '.' -f2 | cut -d '.' -f1` do if [ ! -f /var/run/shaperd.$c.pid ];then echo -n "shaperd.$c " /sbin/shaperd -config=$c fi done echo } stop() { ebegin "Shutting down shaperd: " for c in `ls -1 /etc/shaper | grep "shaper\.[0123456789]\.cfg$" | cut -d '.' -f2 | cut -d '.' -f1` do if [ -f /var/run/shaperd.$c.pid ];then pid=`cat /var/run/shaperd.$c.pid` echo -n "shaperd.$c " if [ `ps ax | grep shaperd | grep $pid | wc -l` -eq 1 ];then kill $pid 2> /dev/null a=0 while [ `ps ax | grep shaperd | grep $pid | wc -l` -eq 1 ];do echo -n "." sleep 1 a=`expr $a + 1` if [ $a -ge 60 ];then kill -9 $pid 2> /dev/null rm -f /var/run/shaperd.$c.pid echo "-9 killed" break fi done rm -f /var/run/shaperd.$c.pid echo killed else rm -f /var/run/shaperd.$c.pid echo "is dead but PID exists - removed PID file." fi fi done } status() { echo -n "Status of shaperd: " echo for c in `ls -1 /etc/shaper | grep "shaper\.[0123456789]\.cfg$" | cut -d '.' -f2 | cut -d '.' -f1` do if [ -f /var/run/shaperd.$c.pid ];then pid=`cat /var/run/shaperd.$c.pid` fin=`ps j $pid | grep shaperd | wc -l` if [ $fin -eq 1 ];then echo "shaperd.$c is working" else echo "shaperd.$c is'nt working but PID file exists" fi else echo "shaperd.$c is stopped" fi done }