From ddfad43b520ffdf72c66e82dc9f43a49e0e96224 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Sat, 15 Mar 2008 20:25:50 +0000 Subject: [PATCH] Reorganize utils unix - added Debian tested - renamed scripts - deleted old scripts --- utils/unix/adempiereServer.sh | 9 - utils/unix/adempiereStop.sh | 2 - utils/unix/adempiere_Debian.sh | 162 ++++++++++++++++++ .../{serverStart.sh => adempiere_RedHat.sh} | 0 ....txt => adempiere_as_service_in_linux.txt} | 0 utils/unix/background server start.txt | 3 - 6 files changed, 162 insertions(+), 14 deletions(-) delete mode 100644 utils/unix/adempiereServer.sh delete mode 100644 utils/unix/adempiereStop.sh create mode 100644 utils/unix/adempiere_Debian.sh rename utils/unix/{serverStart.sh => adempiere_RedHat.sh} (100%) rename utils/unix/{serverStart.txt => adempiere_as_service_in_linux.txt} (100%) delete mode 100644 utils/unix/background server start.txt diff --git a/utils/unix/adempiereServer.sh b/utils/unix/adempiereServer.sh deleted file mode 100644 index ec83339849..0000000000 --- a/utils/unix/adempiereServer.sh +++ /dev/null @@ -1,9 +0,0 @@ -# -cd /home/adempiere/Adempiere/utils -rm nohup.out -nohup ./RUN_Server2.sh & -echo After the server started enter: Ctrl-Z -echo Followed by the shell command: bg -echo Waiting .... -sleep 5 -tail -f nohup.out diff --git a/utils/unix/adempiereStop.sh b/utils/unix/adempiereStop.sh deleted file mode 100644 index 65931ac253..0000000000 --- a/utils/unix/adempiereStop.sh +++ /dev/null @@ -1,2 +0,0 @@ -# Stop Adempiere -/home/adempiere/Adempiere/utils/RUN_Server2Stop.sh diff --git a/utils/unix/adempiere_Debian.sh b/utils/unix/adempiere_Debian.sh new file mode 100644 index 0000000000..df19db92be --- /dev/null +++ b/utils/unix/adempiere_Debian.sh @@ -0,0 +1,162 @@ +#!/bin/bash +# +# 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 +# +# FileTarget: /etc/init.d/adempiere +# FileOwner: root.root +# FilePerms: 0755 +# +# chkconfig: 2345 97 06 +# $Id: adempiere,v 1.1 2006/03/16 05:00:28 cruiz Exp $ + +# initialization +# adjust these variables to your environment +EXECDIR=/home/adempiere/Adempiere +ENVFILE=/home/adempiere/.bashrc +ADEMPIEREUSER=adempiere + +. /lib/lsb/init-functions + +RETVAL=0 +ADEMPIERESTATUS= +MAXITERATIONS=60 # 2 seconds every iteration, max wait 2 minutes) + +getadempierestatus() { + ADEMPIERESTATUSSTRING=$(ps ax | grep -v grep | grep $EXECDIR) + echo $ADEMPIERESTATUSSTRING | grep $EXECDIR &> /dev/null + ADEMPIERESTATUS=$? +} + +start () { + getadempierestatus + if [ $ADEMPIERESTATUS -eq 0 ] ; then + echo "adempiere is already running" + return 1 + fi + echo -n "Starting ADempiere ERP: " + source $ENVFILE + 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 "cd $EXECDIR/utils;$EXECDIR/utils/RUN_Server2.sh &> $LOGFILE &" + RETVAL=$? + if [ $RETVAL -eq 0 ] ; then + # wait for server to be confirmed as started in logfile + STATUSTEST=0 + ITERATIONS=0 + while [ $STATUSTEST -eq 0 ] ; do + sleep 2 + tail -n 5 $LOGFILE | grep 'INFO.*\[Server\].*Started in' &> /dev/null && STATUSTEST=1 + echo -n "." + ITERATIONS=`expr $ITERATIONS + 1` + if [ $ITERATIONS -gt $MAXITERATIONS ] + then + break + fi + done + if [ $STATUSTEST -eq 0 ] + then + 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 + log_failure_msg "Service not started" + echo + fi + return $RETVAL +} + +stop () { + getadempierestatus + if [ $ADEMPIERESTATUS -ne 0 ] ; then + echo "adempiere is already stopped" + return 1 + fi + echo -n "Stopping ADempiere ERP: " + source $ENVFILE + export LASTLOG=`ls -t $ADEMPIERE_HOME/jboss/server/adempiere/log/adempiere_??????????????.log | head -1` + su $ADEMPIEREUSER -c "cd $EXECDIR/utils;$EXECDIR/utils/RUN_Server2Stop.sh &> /dev/null &" + RETVAL=$? + if [ $RETVAL -eq 0 ] ; then + # wait for server to be confirmed as halted in logfile + STATUSTEST=0 + ITERATIONS=0 + while [ $STATUSTEST -eq 0 ] ; do + sleep 2 + tail -n 5 $LASTLOG | grep 'Halting VM' &> /dev/null && STATUSTEST=1 + echo -n "." + ITERATIONS=`expr $ITERATIONS + 1` + if [ $ITERATIONS -gt $MAXITERATIONS ] + then + break + fi + done + if [ $STATUSTEST -eq 0 ] + then + log_warning_msg "Service hasn't stopped within the timeout allowed, please review file $LASTLOG to see the status of the service" + else + log_success_msg "Service started" + fi + echo + else + log_failure_msg "Service not started" + echo + fi + return $RETVAL +} + +restart () { + stop + start +} + +condrestart () { + getadempierestatus + if [ $ADEMPIERESTATUS -eq 0 ] ; then + restart + fi +} + +rhstatus () { + getadempierestatus + if [ $ADEMPIERESTATUS -eq 0 ] ; then + echo + echo "adempiere is running:" + ps ax | grep -v grep | grep $EXECDIR | sed 's/^[[:space:]]*\([[:digit:]]*\).*:[[:digit:]][[:digit:]][[:space:]]\(.*\)/\1 \2/' + echo + else + echo "adempiere is stopped" + fi +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + reload) + restart + ;; + restart) + restart + ;; + condrestart) + condrestart + ;; + status) + rhstatus + ;; + *) + echo $"Usage: $0 {start|stop|reload|restart|condrestart|status}" + exit 1 +esac + +exit 0 diff --git a/utils/unix/serverStart.sh b/utils/unix/adempiere_RedHat.sh similarity index 100% rename from utils/unix/serverStart.sh rename to utils/unix/adempiere_RedHat.sh diff --git a/utils/unix/serverStart.txt b/utils/unix/adempiere_as_service_in_linux.txt similarity index 100% rename from utils/unix/serverStart.txt rename to utils/unix/adempiere_as_service_in_linux.txt diff --git a/utils/unix/background server start.txt b/utils/unix/background server start.txt deleted file mode 100644 index e0e1d62fe6..0000000000 --- a/utils/unix/background server start.txt +++ /dev/null @@ -1,3 +0,0 @@ -Please find a few scripts to start the adempiere server in background. -If you have a better one or suggestions for improvement, -please file a support request!