improve Identation of the file and added proper Header info.

This commit is contained in:
trifonnt 2009-10-14 09:58:53 +00:00
parent 0858087435
commit 5afcf50f8a
1 changed files with 101 additions and 93 deletions

View File

@ -1,22 +1,24 @@
#!/bin/bash #!/bin/bash -e
#
# FileName: adempiere.init
# Description: adempiere erp software startup and shutdown
# Vendor: K.K. Alice
# Created: 05. April 2004
# Author: S. Christians
# Updated: Carlos Ruiz - globalqss - version for Debian tested in Knoppix
# #
### BEGIN INIT INFO
# Provides: adempiere adempiere-3.5
# Required-Start: postgresql
# Required-Stop: postgresql
# Default-Start: 2 3 4 5
# Default-Stop: 1
# Short-Description: ADempiere 3.5 server
# Description: Provides ADempiere ERP-CRM Server startup and shutdown script. Requires PostgreSQL server.
# FileTarget: /etc/init.d/adempiere # FileTarget: /etc/init.d/adempiere
# FileOwner: root.root # FileOwner: root.root
# FilePerms: 0755 # FilePerms: 0755
# #
# chkconfig: 2345 97 06 # chkconfig: 2345 97 06
# $Id: adempiere,v 1.1 2006/03/16 05:00:28 cruiz Exp $ ### END INIT INFO
# initialization # initialization
# adjust these variables to your environment # adjust these variables to your environment
EXECDIR=/home/adempiere/Adempiere EXECDIR=/opt/adempiere/Adempiere
ADEMPIEREUSER=adempiere ADEMPIEREUSER=adempiere
# Instead of using ENVFILE you can set JAVA_HOME, ADEMPIERE_HOME and add JAVA_HOME/bin to PATH # Instead of using ENVFILE you can set JAVA_HOME, ADEMPIERE_HOME and add JAVA_HOME/bin to PATH
# in this case you can comment the source lines for ENVFILE below # in this case you can comment the source lines for ENVFILE below
@ -32,56 +34,56 @@ ADEMPIERESTATUS=
MAXITERATIONS=60 # 2 seconds every iteration, max wait 2 minutes) MAXITERATIONS=60 # 2 seconds every iteration, max wait 2 minutes)
getadempierestatus() { getadempierestatus() {
ADEMPIERESTATUSSTRING=$(ps ax | grep -v grep | grep $EXECDIR) ADEMPIERESTATUSSTRING=$(ps ax | grep -v grep | grep $EXECDIR)
echo $ADEMPIERESTATUSSTRING | grep -q $EXECDIR echo $ADEMPIERESTATUSSTRING | grep -q $EXECDIR
ADEMPIERESTATUS=$? ADEMPIERESTATUS=$?
} }
start () { start () {
getadempierestatus getadempierestatus
if [ $ADEMPIERESTATUS -eq 0 ] ; then if [ $ADEMPIERESTATUS -eq 0 ] ; then
echo "adempiere is already running" echo "ADempiere is already running"
return 1 return 1
fi fi
echo -n "Starting ADempiere ERP: " echo -n "Starting ADempiere ERP: "
. $ENVFILE . $ENVFILE
export LOGFILE=$ADEMPIERE_HOME/jboss/server/adempiere/log/adempiere_`date +%Y%m%d%H%M%S`.log export LOGFILE=$ADEMPIERE_HOME/jboss/server/adempiere/log/adempiere_`date +%Y%m%d%H%M%S`.log
su $ADEMPIEREUSER -c "mkdir -p $ADEMPIERE_HOME/jboss/server/adempiere/log" su $ADEMPIEREUSER -c "mkdir -p $ADEMPIERE_HOME/jboss/server/adempiere/log"
su $ADEMPIEREUSER -c "cd $EXECDIR/utils;$EXECDIR/utils/RUN_Server2.sh &> $LOGFILE &" su $ADEMPIEREUSER -c "cd $EXECDIR/utils;$EXECDIR/utils/RUN_Server2.sh &> $LOGFILE &"
RETVAL=$? RETVAL=$?
if [ $RETVAL -eq 0 ] ; then if [ $RETVAL -eq 0 ] ; then
# wait for server to be confirmed as started in logfile # wait for server to be confirmed as started in logfile
STATUSTEST=0 STATUSTEST=0
ITERATIONS=0 ITERATIONS=0
while [ $STATUSTEST -eq 0 ] ; do while [ $STATUSTEST -eq 0 ] ; do
sleep 2 sleep 2
tail -n 5 $LOGFILE | grep -q 'INFO.*\[Server\].*Started in' && STATUSTEST=1 tail -n 5 $LOGFILE | grep -q 'INFO.*\[Server\].*Started in' && STATUSTEST=1
echo -n "." echo -n "."
ITERATIONS=`expr $ITERATIONS + 1` ITERATIONS=`expr $ITERATIONS + 1`
if [ $ITERATIONS -gt $MAXITERATIONS ] if [ $ITERATIONS -gt $MAXITERATIONS ]
then then
break break
fi fi
done done
if [ $STATUSTEST -eq 0 ] if [ $STATUSTEST -eq 0 ]
then then
log_warning_msg "Service hasn't started within the timeout allowed, please review file $LOGFILE to see the status of the service" log_warning_msg "Service hasn't started within the timeout allowed, please review file $LOGFILE to see the status of the service"
else
log_success_msg "Service started"
fi
echo
else else
log_failure_msg "Service not started" log_success_msg "Service started"
echo
fi fi
return $RETVAL echo
else
log_failure_msg "Service not started"
echo
fi
return $RETVAL
} }
stop () { stop () {
getadempierestatus getadempierestatus
if [ $ADEMPIERESTATUS -ne 0 ] ; then if [ $ADEMPIERESTATUS -ne 0 ] ; then
echo "adempiere is already stopped" echo "ADempiere is already stopped"
return 1 return 1
fi fi
echo -n "Stopping ADempiere ERP: " echo -n "Stopping ADempiere ERP: "
. $ENVFILE . $ENVFILE
@ -89,80 +91,86 @@ stop () {
su $ADEMPIEREUSER -c "cd $EXECDIR/utils;$EXECDIR/utils/RUN_Server2Stop.sh &> /dev/null &" su $ADEMPIEREUSER -c "cd $EXECDIR/utils;$EXECDIR/utils/RUN_Server2Stop.sh &> /dev/null &"
RETVAL=$? RETVAL=$?
if [ $RETVAL -eq 0 ] ; then if [ $RETVAL -eq 0 ] ; then
# wait for server to be confirmed as halted in logfile # wait for server to be confirmed as halted in logfile
STATUSTEST=0 STATUSTEST=0
ITERATIONS=0 ITERATIONS=0
while [ $STATUSTEST -eq 0 ] ; do while [ $STATUSTEST -eq 0 ] ; do
sleep 2 sleep 2
tail -n 9 $LASTLOG | grep -q "$STOPMESSAGE" && STATUSTEST=1 tail -n 9 $LASTLOG | grep -q "$STOPMESSAGE" && STATUSTEST=1
echo -n "." echo -n "."
ITERATIONS=`expr $ITERATIONS + 1` ITERATIONS=`expr $ITERATIONS + 1`
if [ $ITERATIONS -gt $MAXITERATIONS ] if [ $ITERATIONS -gt $MAXITERATIONS ]
then then
break break
fi fi
done done
if [ $STATUSTEST -eq 0 ] if [ $STATUSTEST -eq 0 ]
then then
log_warning_msg "Service hasn't stopped within the timeout allowed, please review file $LASTLOG to see the status of the service" log_warning_msg "Service hasn't stopped within the timeout allowed, please review file $LASTLOG to see the status of the service"
else else
log_success_msg "Service stopped" log_success_msg "Service stopped"
fi fi
echo echo
else else
log_failure_msg "Service not stopped" log_failure_msg "Service not stopped"
echo echo
fi fi
return $RETVAL return $RETVAL
} }
restart () { restart () {
stop stop
sleep 1 sleep 1
start start
} }
condrestart () { condrestart () {
getadempierestatus getadempierestatus
if [ $ADEMPIERESTATUS -eq 0 ] ; then if [ $ADEMPIERESTATUS -eq 0 ] ; then
restart restart
fi fi
} }
rhstatus () { rhstatus () {
getadempierestatus getadempierestatus
if [ $ADEMPIERESTATUS -eq 0 ] ; then if [ $ADEMPIERESTATUS -eq 0 ] ; then
echo echo
echo "adempiere is running:" echo "ADempiere is running:"
ps ax | grep -v grep | grep $EXECDIR | sed 's/^[[:space:]]*\([[:digit:]]*\).*:[[:digit:]][[:digit:]][[:space:]]\(.*\)/\1 \2/' ps ax | grep -v grep | grep $EXECDIR | sed 's/^[[:space:]]*\([[:digit:]]*\).*:[[:digit:]][[:digit:]][[:space:]]\(.*\)/\1 \2/'
echo echo
else else
echo "adempiere is stopped" echo "ADempiere is stopped"
fi fi
} }
case "$1" in case "$1" in
start) start)
start start
;; ;;
stop)
stop stop)
;; stop
reload) ;;
restart
;; reload)
restart) restart
restart ;;
;;
condrestart) restart)
condrestart restart
;; ;;
status)
rhstatus condrestart)
;; condrestart
*) ;;
echo $"Usage: $0 {start|stop|reload|restart|condrestart|status}"
exit 1 status)
rhstatus
;;
*)
echo $"Usage: $0 {start|stop|reload|restart|condrestart|status}"
exit 1
esac esac
exit 0 exit 0