#!/bin/sh
#  
#  COPYRIGHT 2008, KRUPCZAK.ORG, LLC.
#
#  This program is free software; you can redistribute it and/or
#  modify it under the terms of the GNU General Public License as
#  published by the Free Software Foundation; either version 2 of the
#  License, or (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful, but
#  WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
#  General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
#  USA
#
#  For more information, visit:
#  http://www.krupczak.org/

# Cartographer startup script
#
# 
# copy into /etc/init.d/ and then
# link into the appropriate runlevel directory
# 
# ln -s /etc/init.d/cartographer /etc/rc3.d/S91cartographer

versionStr="KorgVersion 1.03";

CARTOGRAPHERDIR=/opt/cartographer
PATH=$PATH:$CARTOGRAPHERDIR
LD_LIBRARY_PATH=/opt/cartographer:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH
RETVAL=0

ARCH=`uname -p`
RELEASE=`uname -r`

case "$ARCH" in

   i386)
      DAEMON="xmpd-solx86"
      ;;

   sparc)
      DAEMON="xmpd-solaris"
      ;;

   *)
      DAEMON="xmpd-solaris"
      ;;
esac

case "$1" in

   start)
       cd $CARTOGRAPHERDIR
       if [ -x $DAEMON ]; then
          echo "Starting Cartographer"
          $DAEMON -b -g
       fi
       ;;

   stop)
       echo "Stopping Cartographer"
       pkill -u root $DAEMON
       RETVAL=$?
       # sleep while we wait for shutdown to occur gracefully
       sleep 30
       ;;

   restart)
       $0 stop
       $0 start
       RETVAL=$?
       ;;

   *)
       echo "Usage: /etc/init.d/cartographer {start|stop|restart}"
       exit 1


esac
exit $RETVAL

