directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ole Ersoy <ole.er...@gmail.com>
Subject [RPM Installer] Start/Stop Script Take 2
Date Thu, 22 Mar 2007 04:31:09 GMT
OK - I think this one is a little cleaner than in take 1.
I also removed the pseudo parameterization and just put apacheds or 
APACHEDS everywhere,
so that it's easier to read.  I'll turn it into a generic template later.

#!/bin/sh
# 
-----------------------------------------------------------------------------
# Start/Stop Script for the APACHEDS Server
#
# Environment Variable Prequisites
#
#  APACHEDS_HOME     FHS Standard server home /usr/share/apacheds-1.0.1/
#
#  JAVA_HOME         Must point at your Java Development Kit installation.
#                                   Required to run the with the "debug" 
or "javac" argument.
#
#  APACHEDS_USER     ApacheDS will by default run under
#                                         user apacheds created during 
installation.
#
#  APACHEDS_TMP_DIR  FHS Standard temp directory set to 
/var/tmp/apacheds-1.0.1/
#
#  APACHEDS_PID_FILE FHS Standard pid file location set to 
/var/run/apacheds-1.0.1/server.pid
#
#  APACHEDS_CONF_DIR FHS Standard configuration directory set to 
/etc/conf/apacheds-1.0.1/
#
#  APACHEDS_LOG_DIR  FHS Standard logging directory set to 
/var/log/apacheds-1.0.1
#
# 
-----------------------------------------------------------------------------

if [ -z "$JAVA_HOME" ] ; then
  echo "Warning: JAVA_HOME environment variable is not set."
  echo "  If scrip fails because sun.* classes could not be found"
  echo "  you will need to set the JAVA_HOME environment variable"
  echo "  to the installation directory of java."
else
  echo JAVA_HOME=$JAVA_HOME
fi

CLASSPATH=$CLASSPATH:$JAVA_HOME/lib/tools.jar
CLASSPATH=$CLASSPATH:$DAEMON_HOME/bootstrapper.jar:$DAEMON_HOME/logger.jar:$DAEMON_HOME/daemon.jar

##TODO / NOTE logger.jar and daemon.jar may be moved to /usr/share/java 
along with other libraries

echo APACHEDS_HOME =/usr/share/apacheds-1.0.1
echo APACHEDS_USER =$USER
echo CLASSPATH     =$CLASSPATH

DAEMON_HOME            =$APACHEDS_HOME/bin
APACHEDS_TMP_DIR       =/var/tmp/apacheds-1.0.1/
APACHEDS_PID_FILE      =/var/run/apacheds-1.0.1/server.pid
APACHEDS_LOG_DIR       =/var/log/apacheds-1.0.1
APACHEDS_CONF_DIR      =/etc/conf/apacheds-1.0.1
APACHEDS_LOG_CONF_FILE =$APACHEDS_CONF_DIR/log4j.properties
APACHEDS_OUT_LOG_FILE  =$APACHEDS_LOG_DIR/stdout.log
APACHEDS_ERR_LOG_FILE  =$APACHEDS_LOG_DIR/stderr.log
FHS_LOCK_DIR           =/var/lock
APACHEDS_LOCK_FILE     =$FHS_LOCK_DIR/LCK..apacheds


cd $APACHEDS_HOME

case "$1" in
  start)
    #
    # Start apacheds
    #
    echo -n $"Starting apacheds server: "
    ulimit -S -c 0 >/dev/null 2>&1
    RETVAL=0
   
    $DAEMON_HOME/apacheds \
    -user $APACHEDS_USER \
    -home $JAVA_HOME \
    -Djava.io.tmpdir=$APACHEDS_TMP_DIR \
    -Dlog4j.configuration=file://$APACHEDS_LOG_CONF_FILE\
    -Xms384m -Xmx384m \
    -pidfile $APACHEDS_PID_FILE \
    -outfile $APACHEDS_OUT_LOG_FILE \
    -errfile $APACHEDS_ERR_LOG_FILE \
    -cp $CLASSPATH \
    org.apache.directory.daemon.JsvcBootstrapper \
    $APACHEDS_HOME start

    echo
    if [ -d FHS_LOCK_DIR ] ; then
       [ "$RETVAL" -eq 0 ] && touch APACHEDS_LOCK_FILE
    fi

    exit $RETVAL
    ;;

  stop)
    #
    # Stop apacheds
    #
    echo -n $"Shutting down apacheds server: "
    RETVAL=0

    $DAEMON_HOME/apacheds \
    -stop \
    -pidfile $APACHEDS_PID_FILE \
    -Dlog4j.configuration=file://$APACHEDS_LOG_CONF_FILE\
    org.apache.directory.daemon.JsvcBootstrapper stop

     echo
     if [ -f APACHEDS_LOCK_FILE ] ; then
    [ "$RETVAL" -eq 0 ] && rm APACHEDS_LOCK_FILE
     fi

    exit $RETVAL
    ;;

  debug)
    #
    # Debug apacheds
    #
    echo -n $"Starting apaches server in debug mode: "
    ulimit -S -c 0 >/dev/null 2>&1
    RETVAL=0
   
    if [ -z "$2" ] ; then
      echo
      echo ========================================================
      echo "Warning: the debug port is not set. Using 5005 default."
      echo ========================================================
      echo
      DEBUG_PORT=5005
    else
      DEBUG_PORT="$2"
    fi
   
    $JAVA_HOME/bin/java\
    -Dlog4j.configuration=file://$APACHEDS_LOG_CONF_FILE\
    -Xms384m -Xmx384m \
    -Dcom.sun.management.jmxremote \
    -Xdebug -Xnoagent -Djava.compiler=NONE\
    -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=$DEBUG_PORT\
    -jar $DAEMON_HOME/bootstrapper.jar \
    $APACHEDS_HOME start
    ;;

  *)
    echo "Usage apacheds [start|stop|debug]"
    exit 1;;
esac


Mime
View raw message