I have a script that I'm making to use to start/stop/etc a JBoss AS (v7.1.1). I'm running on SUSE Enterprise 11, so the provided initscript doesn't work. The problem I'm running into with my script is that the cleanup function is never called.
#!/bin/sh
HOME="/var/rulesserver"
CURRENT=$HOME/logs/current
LOGFILE=$HOME/logs/`date -u +%Y-%m-%d-%H-%M-%S`.log
COMMAND=/usr/local/jboss/bin/standalone.sh
SELF=/usr/sbin/jboss-as-standalone
function cleanup() {
rm $CURRENT
}
function run() {
trap cleanup 1 2 3 6 15
nohup $COMMAND &> $CURRENT
}
case $1 in
"start" )
echo "Starting the server..."
if [ -e $CURRENT ]
then
echo "ERROR: The server is already running"
else
ln -s $LOGFILE $CURRENT
run &
echo "Server started"
fi
;;
"stop" )
echo "Stopping the server..."
killall java
echo "Server stopped"
;;
"status" )
if [ -e $CURRENT ]
then
echo "The server is currently running"
else
echo "The server is currently stopped"
fi
;;
"cleanup" )
cleanup
;;
"restart" )
$SELF stop
$SELF start
;;
* )
$SELF start
;;
esac