Blob Blame History Raw
#!/bin/bash
#
# nasd  Network Audio System daemon
#
# chkconfig: - 88 12
# description:  nasd is sound server for Network Audio System (NAS) \
#               that allows to forward audio stream across network.
#
### BEGIN INIT INFO
# Provides: nasd
# Should-Start: $network $syslog
# Should-Stop: $syslog
# Short-Description: start the NAS daemon
# Description:  nasd is sound server for Network Audio System (NAS) \
#               that allows to forward audio stream across network.
### END INIT INFO

#Servicename
SERVICE=nasd
LOCKFILE=/var/lock/subsys/$SERVICE

#Source function library.
. /etc/rc.d/init.d/functions


[ -f /usr/bin/$SERVICE ] || exit 5

# Source config
if [ -f /etc/sysconfig/$SERVICE ] ; then
	. /etc/sysconfig/$SERVICE
else
	NASD_OPTIONS="-b -local"
fi

RETVAL=0

start() {
#not for now	#Be sure that /dev/dsp is readable
#not for now	chmod g+rw /dev/sound/*

#not for now daemon --user=$SERVICE $SERVICE $NASD_OPTIONS
	#if running return 0
	if [ -n "`/sbin/pidof $SERVICE`" ]; then
		RETVAL=0
		return $RETVAL
	fi
	daemon $SERVICE $NASD_OPTIONS
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && touch $LOCKFILE
	return $RETVAL
}	
stop() {
	#if not running return 0
	if [ -z "`/sbin/pidof $SERVICE`" ]; then
		RETVAL=0
		return $RETVAL
	fi
	killproc $SERVICE
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && rm -f $LOCKFILE
	return $RETVAL
}
rhstatus() {
	status $SERVICE
	
}
restart() {
	stop
	start
}	

case "$1" in
  start)
  	start
	;;
  stop)
  	stop
	;;
  status)
  	rhstatus
	;;
  restart|reload)
  	restart
	;;
  condrestart|try-restart)
  	[ -f $LOCKFILE ] && restart || :
	;;
  *)
	echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart}"
	exit 1
esac

exit $?