#!/bin/sh


case $1 in
  start)
    
    if pgrep icecast 2>/dev/null; then
      echo "Icecast is already running."
      exit 1
    else
      /apps/icecast/bin/icecast -b -c /apps/icecast/etc/icecast.xml &>/dev/null
      RETVAL=$?
      [ $RETVAL -eq 0 ] && echo "Starting Icecast Server."
    fi
    ;;

  stop)

    if pgrep icecast 2>/dev/null; then
      pkill icecast
      RETVAL=$?
      [ $RETVAL -eq 0 ] && echo "Stopping Icecast Server."
      exit 1
    fi


    ;;

  restart)
    stop
    start
    ;;
  *)
    echo "usage: {start|stop|restart}"
esac
exit 0
