#!/bin/sh
#
# imp3sh       This shell starts/stops imp3sh and cleans up temporary files.
#
# chkconfig 2345 20 84
#
# description: imp3sh is an interactive mp3/ogg playlist manager that
#              can be used as a shell or be launched in the background
#              to serialize song play.

# Source function library.
. /etc/init.d/functions

RETVAL=0
prog="imp3sh"

case "$1" in
start)

     echo -n $"Starting $prog:"

     # start a new background session if enabled, clean up if not
     if [ -f /usr/local/share/imp3sh/session ]; then 
        /usr/local/bin/imp3start
     else
        /usr/local/bin/imp3quit
     fi

     success
     ;;

stop)

     echo -n $"Stopping $prog:"

     # shut down old session
     /usr/local/bin/imp3quit

     success
     ;;

restart)

     echo -n $"Restarting $prog:"

     # shut down old session
     /usr/local/bin/imp3quit
 
     # start new session if enabled
     if [ -f /usr/local/share/imp3sh/session ]; then
        /usr/local/bin/imp3start
     fi

     success
     ;;

*)
     echo $"Usage : $0 {start|stop|restart}"
     RETVAL=1

esac
echo
exit $RETVAL
