icecast (include ices) start / stop script for Fedora Core 3
------------------------------------------------------------
[root@blockader init.d]# pwd
/etc/rc.d/init.d
[root@blockader init.d]# cat icecast
#!/bin/bash
#
# chkconfig: 5 99 99
# description: Icecast daemon
#
ICECAST=/usr/bin/icecast
ICES=/usr/local/bin/ices
IC=/etc/icecast.xml
IS=/var/ftp/pub/ogg/BillBoard.xml
ICECAST_LOCKFILE=/var/lock/subsys/icecast
ICES_LOCKFILE=/var/lock/subsys/ices
# Source function library
. /etc/rc.d/init.d/functions
# Check that networking is up.
[ ${NETWORKING} ="yes" ] || exit 0
# Check we have the icecast program installed.
if [ ! -x $ICECAST ] ; then
echo "Cannot find icecast executable!"
exit 0
fi
# Check we have the ices program installed.
if [ ! -x $ICES ] ; then
echo "Cannot find ices executable!"
exit 0
fi
# Check the config files exists.
if [ ! -f $IC ] ; then
echo "Cannot find the icecast runtime control file!"
exit 0
fi
if [ ! -f $IS ] ; then
echo "Cannot find the ices runtime control file!"
exit 0
fi
icecast=$"icecast"
ices=$"ices"
ICECAST_RETVAL=0
ICES_RETVAL=0
start()
{
if [ -f $ICECAST_LOCKFILE ] && [ -f $ICES_LOCKFILE ]; then
echo "icecast and ices are already running!"
exit 0
else
echo -n $"$icecast: "
$ICECAST -c $IC -b
ICECAST_RETVAL=$?
[ "$ICECAST_RETVAL" -eq 0 ] && touch $ICECAST_LOCKFILE
echo
sleep 5
echo -n $"Starting $ices:"
$ICES $IS &
ICES_RETVAL=$?
[ "$ICES_RETVAL" -eq 0 ] && touch $ICES_LOCKFILE
echo
fi
}
stop()
{
echo -n $"Shutting down $icecast:"
killproc $ICECAST -TERM
ICECAST_RETVAL=$?
[ "$ICECAST_RETVAL" -eq 0 ] && rm -f $ICECAST_LOCKFILE
echo
echo -n $"Shutting down $ices:"
killproc $ICES -TERM
ICES_RETVAL=$?
[ "$ICES_RETVAL" -eq 0 ] && rm -f $ICES_LOCKFILE
echo
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
status $ICECAST
ICECAST_RETVAL=$?
status $ICES
ICES_RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|restart|status}"
ICECAST_RETVAL=1
esac
exit $ICECAST_RETVAL
[root@blockader init.d]# ls -al icecast
-rwxr-xr-x 1 root root 1887 Jun 6 19:14 icecast
[root@blockader init.d]# chkconfig --add icecast
[root@blockader init.d]# chkconfig --list icecast
icecast 0:off 1:off 2:off 3:off 4:off 5:on 6:off
|