dimanche 12 février 2017

How to make icecast as service and restart it?

Vote count: 0

I installed Icecast 2.4.3 on my server using direct download to get the latest version available.

In this way, I don't use the version distributed by my distribution (debian 8) and thus don't have the daemon activated by default.

I found a script that I modified with my corresponding paths, but the execution is in error.

The script icecast.sh :

#!/bin/bash
#
# Init file for Icecast server daemon
#
# chkconfig: 345 55 25
# description: Icecast streaming mp3 server daemon
#
# processname: icecast
# config: /etc/icecast.xml
# pidfile: /var/run/icecast.pid

# source function library
# . /etc/rc.d/init.d/functions : returns an error on debian 8
. /lib/lsb/init-functions

# pull in sysconfig settings
[ -f /etc/sysconfig/icecast ] && . /etc/sysconfig/icecast

RETVAL=0
prog="icecast"

# Some functions to make the below more readable
PREFIX=/usr/local
PATH=$PATH:$PREFIX/bin
PIDFILE=/icecast/icecast.pid
CONF_FILE=/icecast/conf/icecast.xml

[ -f $PREFIX/bin/icecast ] || ( echo Failed to locate icecast binary: $PREFIX/bin/icecast && exit )
[ -f $CONF_FILE          ] || ( echo Failed to locate icecast configuration file: $CONF_FILE && exit )

OPTIONS="-b -c $CONF_FILE"

start()
{
    echo -n $"Starting $prog:"
    ulimit -c unlimited # dump core for debugging purposes
    ulimit -n 32768
    daemon icecast icecast $OPTIONS
    RETVAL=$?
    [ "$RETVAL" = 0 ] && touch /var/lock/subsys/icecast
    echo
    pidof icecast > $PIDFILE
    return $RETVAL
}

stop()
{
    echo -n $"Stopping $prog:"
    killproc icecast -TERM
    RETVAL=$?
    [ "$RETVAL" = 0 ] && rm -f /var/lock/subsys/icecast
    echo
    rm -f $PIDFILE
    return $RETVAL
}

reload()
{
    echo -n $"Reloading $prog:"
    killproc icecast -HUP
    RETVAL=$?
    echo
    return $RETVAL
}

condrestart()
{
    [ -e /var/lock/subsys/icecast ] && restart
    return 0
}

case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    restart)
        stop
        # wait for listening sockets to clear
        echo "Waiting 5 seconds before restarting..."
        sleep 5
        start
        ;;
    reload)
        reload
        ;;
    condrestart)
        condrestart
        ;;
    status)
        status icecast
        RETVAL=$?
        ;;
    *)
        echo $"Usage: $0 {start|stop|restart|reload|condrestart|status}"
        RETVAL=1
esac
exit $RETVAL

And the error I'm getting :

# sh icecast.sh status
icecast.sh: line 93: status : unknow command

Q1: How do I fix this error?

Q2: How do I get a functional command like icecast restart service?

Q3: What should I do to restart Icecast automatically if the server restarts itself?

asked 47 secs ago

Let's block ads! (Why?)



How to make icecast as service and restart it?

Aucun commentaire:

Enregistrer un commentaire