#!/bin/bash
. /etc/rc.conf
. /etc/rc.d/functions
[ -f /etc/conf.d/sasc-ng ] && . /etc/conf.d/sasc-ng
PID=$(pidof -o %PPID /usr/sbin/sasc-ng)
case $1 in
start)
stat_busy "Loading dvbloopback kernel module"
[[ -z $DVBLOOPBACK_ARGS ]] && stat_die 1
modprobe dvbloopback $DVBLOOPBACK_ARGS
sleep 1
stat_done
stat_busy "Starting SASC-NG daemon"
[[ -z $SASCNG_ARGS ]] && stat_die 2
[[ -z $CAMDIR ]] && stat_die 3
[[ -z $LOGDIR ]] && stat_die 4
[[ -z $PID ]] && /usr/sbin/sasc-ng -D $SASCNG_ARGS --cam-dir=$CAMDIR -l $LOGDIR/sasc-ng.log
if [ $? -gt 0 ]; then
stat_die 5
else
add_daemon sasc-ng
stat_done
fi
;;
stop)
stat_busy "Stoping SASC-NG daemon"
[[ ! -z $PID ]] && kill $PID &> /dev/null
if [ $? -gt 0 ]; then
stat_die 6
else
rm_daemon sasc-ng
stat_done
fi
stat_busy "Unloading dvbloopback kernel module"
sleep 2
modprobe -r dvbloopback
stat_done
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "usage: $0 {start|stop|restart}" >&2
exit 1
esac