title: How to make icecast as service and restart it?
body: <p>I installed Icecast 2.4.3 on my server using <a href="https://icecast.org/download/" rel="nofollow noreferrer">direct download</a> to get the latest version available.</p>
  
  <p>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.</p>
  
  <p>I found a script that I modified with my corresponding paths, but the execution is in error.</p>
  
  <p>The script <strong><code>icecast.sh</code></strong> :</p>
  
  <pre><code>#!/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 ] &amp;&amp; . /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 &amp;&amp; exit )
  [ -f $CONF_FILE          ] || ( echo Failed to locate icecast configuration file: $CONF_FILE &amp;&amp; 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 ] &amp;&amp; touch /var/lock/subsys/icecast
      echo
      pidof icecast &gt; $PIDFILE
      return $RETVAL
  }
  
  stop()
  {
      echo -n $"Stopping $prog:"
      killproc icecast -TERM
      RETVAL=$?
      [ "$RETVAL" = 0 ] &amp;&amp; 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 ] &amp;&amp; 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
  </code></pre>
  
  <p>And the error I'm getting when I'm doing <code>sh icecast.sh status</code> :</p>
  
  <pre><code># sh icecast.sh status
  icecast.sh: line 93: status : unknow command
  </code></pre>
  
  <p><strong>Q1</strong>: How do I fix this error?</p>
  
  <p><strong>Q2</strong>: How do I get a functional command like <code>icecast restart service</code>?</p>
  
  <p><strong>Q3</strong>: What should I do to restart Icecast automatically if the server restarts itself?</p>