Apache Directory Project - [RPM Installer] Generic start/stop shell script

This is Interesting: Free IT Magazines  
Home > Archive > Apache Directory Project > March 2007 > [RPM Installer] Generic start/stop shell script





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author [RPM Installer] Generic start/stop shell script
Ole Ersoy

2007-03-22, 1:11 am

I've tried to reduce our start/stop shell script to a minimum needed
for RPM (I think Solaris, Mac, *NIX in general).

I still need to test it out of coarse, but I thought I'd throw it out
here in case anyone has a chance to kick it.

Just substitute apacheds for ${name} (It's a pseudo template - The final
one will be a jet template....)


#!/bin/bash
#
# chkconfig: - 91 35
# description: Starts and stops ${name} server.
#
# Shell script to start/stop ${name}
# If you want to change ${name} service settings please modify the
server.xml
# file.
#


# Source function library.
if [ -f /etc/init.d/functions ] ; then
. /etc/init.d/functions
fi

# Source networking configuration.
if [ -f /etc/sysconfig/network ] ; then
. /etc/sysconfig/network
fi

# Check that networking is up.
if [ ! -z "$NETWORKING" ] ; then
if [ "$NETWORKING" = "no" ] ; then
exit 0
fi
fi

prog=$"${name} server"
StringUtils.toUpperCase(${name})_HOME=/usr/share/${name}-${version}
#So for ApacheDS this would be
# APACHEDS_HOME = /usr/share/apacheds-1.0.1

if [ -z "$JAVA_HOME" ] ; then
echo "Error: JAVA_HOME environment variable is not set."
echo "You will need to set the JAVA_HOME environment variable to"
echo "the the path of the root Java installation directory."
echo "See the installation guide for further instructions."
else
echo JAVA_HOME=$JAVA_HOME
fi


DAEMON_HOME=$APACHEDS_HOME/bin
CLASSPATH=$CLASSPATH:$JAVA_HOME/lib/tools.jar

#The statement below will probably be shortened to
#$DAEMON_HOME/bootstrapper.jar
#when we figure out how to use the daemon and logger from
/usr/share/java instead.

CLASSPATH=$CLASSPATH:$DAEMON_HOME/bootstrapper.jar:$DAEMON_HOME/logger.jar:$DAEMON_HOME/daemon.jar
echo CLASSPATH=$CLASSPATH
StringUtils.toUpperCase(${name})_USER=$USER

TMP_DIR=/var/tmp/${name}-${version}
PID_FILE=/var/run/${name}-${version}/server.pid

cd $StringUtils.toUpperCase(${name})_HOME

case "$1" in
start)
#
# Start apacheds
#
echo -n $"Starting $prog: "
ulimit -S -c 0 >/dev/null 2>&1
RETVAL=0

$DAEMON_HOME/apacheds \
-user $StringUtils.toUpperCase(${name})_USER \
-home $JAVA_HOME \
-Djava.io.tmpdir=$TMP_DIR \

-Dlog4j.configuration=file://etc/conf/${name}-${version}/log4j.properties\
-Xms384m -Xmx384m \
-pidfile $PID_FILE \
-outfile /var/log/${name}-${version}/${name}-stdout.log \
-errfile /var/log/${name}-${version}/${name}-stderr.log \
-cp $CLASSPATH \
org.apache.directory.daemon.JsvcBootstrapper \
$StringUtils.toUpperCase(${name})_HOME start

[ "$RETVAL" -eq 0 ] && success $"apacheds server startup" || \
failure $"${name} server start"
echo
if [ -d /var/lock/subsys ] ; then
[ "$RETVAL" -eq 0 ] && touch
/var/${name}-${version}/apacheds.lock
fi

exit $RETVAL
;;

stop)
#
# Stop ${name}
#
echo -n $"Shutting down $prog: "
RETVAL=0

$DAEMON_HOME/${name} \
-stop \
-pidfile $PID_FILE \

-Dlog4j.configuration=file://etc/conf/${name}-${version}/log4j.properties\
org.apache.directory.daemon.JsvcBootstrapper stop

[ "$RETVAL" -eq 0 ] && success $"apacheds server shutdown" || \
failure $"apacheds server shutdown"
echo
if [ -d /var/lock/subsys/apacheds ] ; then
[ "$RETVAL" -eq 0 ] && rm $APACHEDS_HOME/var/apacheds.lock
fi

exit $RETVAL
;;

debug)
#
# Debug ${name}
#
echo -n $"Starting $prog 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://$StringUtils.toUpperCase(${name})_HOME/conf/log4j.properties\
-Xms384m -Xmx384m \
-Dcom.sun.management.jmxremote \
-Xdebug -Xnoagent -Djava.compiler=NONE\
- Xrunjdwp:transport=dt_socket,server=y,su
spend=n,address=$DEBUG_PORT\
-jar $DAEMON_HOME/bootstrapper.jar \
$StringUtils.toUpperCase(${name})_HOME start
;;

*)
echo "Usage ${name} [start|stop|debug]"
exit 1;;
esac




Alex Karasulu

2007-03-27, 1:11 pm

We might want to look at making some things like the min max heap sizes
variable with defaults. However this we can do
later after getting everything working.

Alex


On 3/21/07, Ole Ersoy <ole.ersoy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> I've tried to reduce our start/stop shell script to a minimum needed
> for RPM (I think Solaris, Mac, *NIX in general).
>
> I still need to test it out of coarse, but I thought I'd throw it out
> here in case anyone has a chance to kick it.
>
> Just substitute apacheds for ${name} (It's a pseudo template - The final
> one will be a jet template....)
>
>
> #!/bin/bash
> #
> # chkconfig: - 91 35
> # description: Starts and stops ${name} server.
> #
> # Shell script to start/stop ${name}
> # If you want to change ${name} service settings please modify the
> server.xml
> # file.
> #
>
>
> # Source function library.
> if [ -f /etc/init.d/functions ] ; then
> . /etc/init.d/functions
> fi
>
> # Source networking configuration.
> if [ -f /etc/sysconfig/network ] ; then
> . /etc/sysconfig/network
> fi
>
> # Check that networking is up.
> if [ ! -z "$NETWORKING" ] ; then
> if [ "$NETWORKING" = "no" ] ; then
> exit 0
> fi
> fi
>
> prog=$"${name} server"
> StringUtils.toUpperCase(${name})_HOME=/usr/share/${name}-${version}
> #So for ApacheDS this would be
> # APACHEDS_HOME = /usr/share/apacheds-1.0.1
>
> if [ -z "$JAVA_HOME" ] ; then
> echo "Error: JAVA_HOME environment variable is not set."
> echo "You will need to set the JAVA_HOME environment variable to"
> echo "the the path of the root Java installation directory."
> echo "See the installation guide for further instructions."
> else
> echo JAVA_HOME=$JAVA_HOME
> fi
>
>
> DAEMON_HOME=$APACHEDS_HOME/bin
> CLASSPATH=$CLASSPATH:$JAVA_HOME/lib/tools.jar
>
> #The statement below will probably be shortened to
> #$DAEMON_HOME/bootstrapper.jar
> #when we figure out how to use the daemon and logger from
> /usr/share/java instead.
>
>
> CLASSPATH=$CLASSPATH:$DAEMON_HOME/bootstrapper.jar:$DAEMON_HOME/logger.jar:$DAEMON_HOME/daemon.jar
> echo CLASSPATH=$CLASSPATH
> StringUtils.toUpperCase(${name})_USER=$USER
>
> TMP_DIR=/var/tmp/${name}-${version}
> PID_FILE=/var/run/${name}-${version}/server.pid
>
> cd $StringUtils.toUpperCase(${name})_HOME
>
> case "$1" in
> start)
> #
> # Start apacheds
> #
> echo -n $"Starting $prog: "
> ulimit -S -c 0 >/dev/null 2>&1
> RETVAL=0
>
> $DAEMON_HOME/apacheds \
> -user $StringUtils.toUpperCase(${name})_USER \
> -home $JAVA_HOME \
> -Djava.io.tmpdir=$TMP_DIR \
>
> -Dlog4j.configuration=file://etc/conf/${name}-${version}/log4j.properties\
> -Xms384m -Xmx384m \
> -pidfile $PID_FILE \
> -outfile /var/log/${name}-${version}/${name}-stdout.log \
> -errfile /var/log/${name}-${version}/${name}-stderr.log \
> -cp $CLASSPATH \
> org.apache.directory.daemon.JsvcBootstrapper \
> $StringUtils.toUpperCase(${name})_HOME start
>
> [ "$RETVAL" -eq 0 ] && success $"apacheds server startup" || \
> failure $"${name} server start"
> echo
> if [ -d /var/lock/subsys ] ; then
> [ "$RETVAL" -eq 0 ] && touch
> /var/${name}-${version}/apacheds.lock
> fi
>
> exit $RETVAL
> ;;
>
> stop)
> #
> # Stop ${name}
> #
> echo -n $"Shutting down $prog: "
> RETVAL=0
>
> $DAEMON_HOME/${name} \
> -stop \
> -pidfile $PID_FILE \
>
> -Dlog4j.configuration=file://etc/conf/${name}-${version}/log4j.properties\
> org.apache.directory.daemon.JsvcBootstrapper stop
>
> [ "$RETVAL" -eq 0 ] && success $"apacheds server shutdown" || \
> failure $"apacheds server shutdown"
> echo
> if [ -d /var/lock/subsys/apacheds ] ; then
> [ "$RETVAL" -eq 0 ] && rm $APACHEDS_HOME/var/apacheds.lock
> fi
>
> exit $RETVAL
> ;;
>
> debug)
> #
> # Debug ${name}
> #
> echo -n $"Starting $prog 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://$StringUtils.toUpperCase
> (${name})_HOME/conf/log4j.properties\
> -Xms384m -Xmx384m \
> -Dcom.sun.management.jmxremote \
> -Xdebug -Xnoagent -Djava.compiler=NONE\
> - Xrunjdwp:transport=dt_socket,server=y,su
spend=n,address=$DEBUG_PORT\
> -jar $DAEMON_HOME/bootstrapper.jar \
> $StringUtils.toUpperCase(${name})_HOME start
> ;;
>
> *)
> echo "Usage ${name} [start|stop|debug]"
> exit 1;;
> esac
>
>
>
>


Ole Ersoy

2007-03-28, 1:11 am

Yeah - Would be nice if the server.xml file could contain default
alternatives.

Anyone know if we can inject min/max heap size parameters into the JVM
post startup?

Thanks,
- Ole


Alex Karasulu wrote:
> We might want to look at making some things like the min max heap
> sizes variable with defaults. However this we can do
> later after getting everything working.
>
> Alex
>
>
> On 3/21/07, *Ole Ersoy* <ole.ersoy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
> <mailto:ole.ersoy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>> wrote:
>
> I've tried to reduce our start/stop shell script to a minimum needed
> for RPM (I think Solaris, Mac, *NIX in general).
>
> I still need to test it out of coarse, but I thought I'd throw it out
> here in case anyone has a chance to kick it.
>
> Just substitute apacheds for ${name} (It's a pseudo template - The
> final
> one will be a jet template....)
>
>
> #!/bin/bash
> #
> # chkconfig: - 91 35
> # description: Starts and stops ${name} server.
> #
> # Shell script to start/stop ${name}
> # If you want to change ${name} service settings please modify the
> server.xml
> # file.
> #
>
>
> # Source function library.
> if [ -f /etc/init.d/functions ] ; then
> . /etc/init.d/functions
> fi
>
> # Source networking configuration.
> if [ -f /etc/sysconfig/network ] ; then
> . /etc/sysconfig/network
> fi
>
> # Check that networking is up.
> if [ ! -z "$NETWORKING" ] ; then
> if [ "$NETWORKING" = "no" ] ; then
> exit 0
> fi
> fi
>
> prog=$"${name} server"
> StringUtils.toUpperCase(${name})_HOME=/usr/share/${name}-${version}
> #So for ApacheDS this would be
> # APACHEDS_HOME = /usr/share/apacheds-1.0.1
>
> if [ -z "$JAVA_HOME" ] ; then
> echo "Error: JAVA_HOME environment variable is not set."
> echo "You will need to set the JAVA_HOME environment variable to"
> echo "the the path of the root Java installation directory."
> echo "See the installation guide for further instructions."
> else
> echo JAVA_HOME=$JAVA_HOME
> fi
>
>
> DAEMON_HOME=$APACHEDS_HOME/bin
> CLASSPATH=$CLASSPATH:$JAVA_HOME/lib/tools.jar
>
> #The statement below will probably be shortened to
> #$DAEMON_HOME/bootstrapper.jar
> #when we figure out how to use the daemon and logger from
> /usr/share/java instead.
>
> CLASSPATH=$CLASSPATH:$DAEMON_HOME/bootstrapper.jar:$DAEMON_HOME/logger.jar:$DAEMON_HOME/daemon.jar
>
> echo CLASSPATH=$CLASSPATH
> StringUtils.toUpperCase(${name})_USER=$USER
>
> TMP_DIR=/var/tmp/${name}-${version}
> PID_FILE=/var/run/${name}-${version}/server.pid
>
> cd $StringUtils.toUpperCase(${name})_HOME
>
> case "$1" in
> start)
> #
> # Start apacheds
> #
> echo -n $"Starting $prog: "
> ulimit -S -c 0 >/dev/null 2>&1
> RETVAL=0
>
> $DAEMON_HOME/apacheds \
> -user $StringUtils.toUpperCase(${name})_USER \
> -home $JAVA_HOME \
> -Djava.io.tmpdir=$TMP_DIR \
>
> -Dlog4j.configuration=file://etc/conf/${name}-${version}/log4j.properties\
> -Xms384m -Xmx384m \
> -pidfile $PID_FILE \
> -outfile /var/log/${name}-${version}/${name}- stdout.log \
> -errfile /var/log/${name}-${version}/${name}-stderr.log \
> -cp $CLASSPATH \
> org.apache.directory.daemon.JsvcBootstrapper \
> $StringUtils.toUpperCase(${name})_HOME start
>
> [ "$RETVAL" -eq 0 ] && success $"apacheds server startup" || \
> failure $"${name} server start"
> echo
> if [ -d /var/lock/subsys ] ; then
> [ "$RETVAL" -eq 0 ] && touch
> /var/${name}-${version}/apacheds.lock
> fi
>
> exit $RETVAL
> ;;
>
> stop)
> #
> # Stop ${name}
> #
> echo -n $"Shutting down $prog: "
> RETVAL=0
>
> $DAEMON_HOME/${name} \
> -stop \
> -pidfile $PID_FILE \
>
> -
> Dlog4j.configuration=file://etc/conf/${name}-${version}/log4j.properties\
> org.apache.directory.daemon.JsvcBootstrapper stop
>
> [ "$RETVAL" -eq 0 ] && success $"apacheds server shutdown" || \
> failure $"apacheds server shutdown"
> echo
> if [ -d /var/lock/subsys/apacheds ] ; then
> [ "$RETVAL" -eq 0 ] && rm $APACHEDS_HOME/var/apacheds.lock
> fi
>
> exit $RETVAL
> ;;
>
> debug)
> #
> # Debug ${name}
> #
> echo -n $"Starting $prog 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://$StringUtils.toUpperCase(${name})_HOME/conf/log4j.properties\
> -Xms384m -Xmx384m \
> -Dcom.sun.management.jmxremote \
> -Xdebug -Xnoagent -Djava.compiler=NONE\
>
> - Xrunjdwp:transport=dt_socket,server=y,su
spend=n,address=$DEBUG_PORT\
> -jar $DAEMON_HOME/bootstrapper.jar \
> $StringUtils.toUpperCase(${name})_HOME start
> ;;
>
> *)
> echo "Usage ${name} [start|stop|debug]"
> exit 1;;
> esac
>
>
>
>



Alex Karasulu

2007-03-29, 1:11 am

Post startup? Hmmm I don't think so since these parameters are needed to
initialize the
different memory pools for various memory models. However I could be wrong.

Regards,
Alex


On 3/28/07, Ole Ersoy <ole.ersoy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> Yeah - Would be nice if the server.xml file could contain default
> alternatives.
>
> Anyone know if we can inject min/max heap size parameters into the JVM
> post startup?
>
> Thanks,
> - Ole
>
>
> Alex Karasulu wrote:
> out
> CLASSPATH=$CLASSPATH:$DAEMON_HOME/bootstrapper.jar:$DAEMON_HOME/logger.jar:$DAEMON_HOME/daemon.jar
> Dlog4j.configuration=file://etc/conf/${name}-${version}/log4j.properties\
> Dlog4j.configuration=file://etc/conf/${name}-${version}/log4j.properties\
> $APACHEDS_HOME/var/apacheds.lock
> (${name})_HOME/conf/log4j.properties\
> - Xrunjdwp:transport=dt_socket,server=y,su
spend=n,address=$DEBUG_PORT\
>
>


Ole Ersoy

2007-03-29, 1:11 am

I wonder if this might fix things?

http://jakarta.apache.org/commons/launcher/

It says it could be used to pass JVM arguments post startup.

So if that's the case maybe we can set the
-Xmx and -Xms parameters in the configuration
file...and alles gut.

Has anyone played with this?

Cheers,
- Ole




Alex Karasulu wrote:
> Post startup? Hmmm I don't think so since these parameters are needed
> to initialize the
> different memory pools for various memory models. However I could be
> wrong.
>
> Regards,
> Alex
>
>
> On 3/28/07, *Ole Ersoy* <ole.ersoy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
> <mailto:ole.ersoy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>> wrote:
>
> Yeah - Would be nice if the server.xml file could contain default
> alternatives.
>
> Anyone know if we can inject min/max heap size parameters into the
> JVM
> post startup?
>
> Thanks,
> - Ole
>
>
> Alex Karasulu wrote:
> <mailto:ole.ersoy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> minimum needed
> throw it out
> - The
> modify the
> (${name})_HOME=/usr/share/${name}-${version}
> variable to"
> CLASSPATH=$CLASSPATH:$DAEMON_HOME/bootstrapper.jar:$DAEMON_HOME/logger.jar:$DAEMON_HOME/daemon.jar
>
> -Dlog4j.configuration=file://etc/conf/${name}-${version}/log4j.properties\
> || \
> Dlog4j.configuration=file://etc/conf/${name}-${version}/log4j.properties\
> shutdown" || \
> $APACHEDS_HOME/var/apacheds.lock
> ========================================
================
> default."
> ========================================
================
> -Dlog4j.configuration=file://$StringUtils.toUpperCase(${name})_HOME/conf/log4j.properties\
>
> - Xrunjdwp:transport=dt_socket,server=y,su
spend=n,address=$DEBUG_PORT\
>
>



Alex Karasulu

2007-03-29, 1:11 am

No I have not tried it but I'm wondering if this is a launcher for a class
and not the jvm. It sounds like it's more like the daemon bootstrapper
code.

However give it a try and let me know I could be totally wrong about it.
Just guessing from past history playing with the Tomcat launcher code while
formulating the daemon bootstrappers. There's a lot that's borrowed from
there I think if this launcher thingy is what I think it is.

Alex


On 3/28/07, Ole Ersoy <ole.ersoy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> I wonder if this might fix things?
>
> http://jakarta.apache.org/commons/launcher/
>
> It says it could be used to pass JVM arguments post startup.
>
> So if that's the case maybe we can set the
> -Xmx and -Xms parameters in the configuration
> file...and alles gut.
>
> Has anyone played with this?
>
> Cheers,
> - Ole
>
>
>
>
> Alex Karasulu wrote:
> CLASSPATH=$CLASSPATH:$DAEMON_HOME/bootstrapper.jar:$DAEMON_HOME/logger.jar:$DAEMON_HOME/daemon.jar
> Dlog4j.configuration=file://etc/conf/${name}-${version}/log4j.properties\
> Dlog4j.configuration=file://etc/conf/${name}-${version}/log4j.properties\
> (${name})_HOME/conf/log4j.properties\
> - Xrunjdwp:transport=dt_socket,server=y,su
spend=n,address=$DEBUG_PORT\
>
>


Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com