Skip to content

Instantly share code, notes, and snippets.

@psychosquirrel85
Created June 18, 2016 00:08
Show Gist options
  • Save psychosquirrel85/ed878026f306945307b067adce928479 to your computer and use it in GitHub Desktop.
Save psychosquirrel85/ed878026f306945307b067adce928479 to your computer and use it in GitHub Desktop.
ices 0.4 Startup script for RHEL/CentOS/Amazon Linux
#!/bin/sh
#
# ices This shell script takes care of starting and stopping
# the iceS Source streamer.
#
# chkconfig: - 86 14
# description: IceS is a multimedia Source Streaming daemon.
# processname: ices
# pidfile: /var/log/ices/ices.pid
# config: /etc/ices.conf
# Source function library.
. /etc/rc.d/init.d/functions
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
NAME=ices
DESC="ices0.4 Icecast client"
ICES="/usr/local/bin/ices"
ICES_CONFIGFILE="/etc/ices.conf"
USER=ices
SU="su - $USER -s /bin/bash -c"
[ -x /usr/local/bin/ices ] || exit 0
case "$1" in
start)
echo -n "Starting $DESC: "
daemon $SU \"$ICES -c $ICES_CONFIGFILE\"
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/ices
;;
stop)
echo -n "Stopping $DESC: "
killproc $NAME
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/ices
;;
skip-track)
echo -n "Skipping to next track"
killproc $ICES -USR1
RETVAL=$?
echo
;;
reload)
echo -n "Reloading playlist file"
killproc $ICES -HUP
RETVAL=$?
echo
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: $0 {start|stop|restart|reload|skip-track}" >&2
exit 1
;;
esac
exit $RETVAL
@psychosquirrel85
Copy link
Author

Be warned, IceS will start, all though it will say FAILED. This is because the ices program returns a non-zero code when it is successful. The change can be made in the src/setup.c file in the ices_setup_shutdown routine.

Change exit (1) to exit (0) on line 136. Save the file and and configure, make, make install
Then the script will work as intended.

Additions to the script include the ability to reload the playlist file and to skip to the next track in the playlist file. IceS automatically detects changes in the playlist file so reloading the playlist file gives you the ability to change the playlist file in the ices configuration file and reload it.

This script also assumes that you have a dedicated user for running IceS I used su - $USER -s /bin/bash -c to allow the application to start as the ices user instead of root.

If you are using IceCast on the same server, change the line in this startup script file
chkconfig: - 86 14
So that IceS starts after IceCast and shuts down before IceCast.
IceCast starts at 85 and shuts down at 15 for me so I changed my script for IceS to be 86 14.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment