#!/bin/sh

# reptile Start the reptile P2P client.

# This script is designed to startup Reptile from init.  You only need to modify
# the following variables to reflect your installation
#
# Java needs to be installed and running for this script to function correctly.

NAME=reptile
LOGFILE=/var/log/reptile-cvs.log
REPTILE_HOME=/usr/local/reptile-cvs

#make sure everything is setup correctly.

if [ ! -d $REPTILE_HOME ]; then
    
    echo "$NAME home directory does not exist!"
    exit
    
fi 

case "$1" in
  start)
    echo -n "Starting daemon: $NAME"

    #change to the reptile home directory because everything is assumed to be
    #relative
    cd $REPTILE_HOME
    
    #startup reptile and background the process.
    ./$NAME-startup.sh >> $LOGFILE &
    echo done
    ;;

  stop)
    echo -n "Stopping daemon: $NAME"
    start-stop-daemon --stop --pidfile $PIDFILE --oknodo --exec $DAEMON
    cd $REPTILE_HOME
    ./$NAME-shutdown.sh
    echo done
    ;;

  restart)
    $0 reload-modules
    exit $?
    ;;

  *)
    echo "Usage: /etc/init.d/$NAME {start|stop|reload|restart}"
    exit 1
    ;;
esac
