svc

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

ntpd (427B)


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