svc

Simple service scripts and examples, to be used everywhere.
git clone git://r-36.net/svc
Log | Files | Refs | README | LICENSE

fancontrol (399B)


      1 #!/bin/sh
      2 
      3 set -x
      4 
      5 SERVICE="fancontrol"
      6 
      7 [ -e "/bin/svc.d/default/$SERVICE" ] && . "/bin/svc.d/default/$SERVICE"
      8 
      9 BIN="/usr/sbin/$SERVICE"
     10 
     11 PID=$(pidof -o %PPID -x $BIN)
     12 
     13 case $1 in
     14 	-s)
     15 		[ -z "$PID" ] && {
     16 			rm /run/fancontrol.pid
     17 			$BIN $PARAMS
     18 		}
     19 		;;
     20 	-k)
     21 		[ -n "$PID" ] && {
     22 			for p in $PID;
     23 			do
     24 				kill -9 $p &> /dev/null;
     25 			done
     26 		}
     27 		;;
     28 	*)
     29 		echo "usage: $0 -s|-k"
     30 		exit 1
     31 esac
     32