0% found this document useful (0 votes)
243 views

Apache Ofbiz Auto Startup Scripts.

This bash script is an init script used to start and stop the Apache Ofbiz open source enterprise automation software. It sets various environment variables needed to run Ofbiz, such as the Java home and classpath locations. When starting Ofbiz, it checks if it is already running, removes log files, and runs the Java process in the background writing output to log files. When stopping Ofbiz, it attempts to shut it down gracefully and if needed will terminate processes forcefully.

Uploaded by

hillol001
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
243 views

Apache Ofbiz Auto Startup Scripts.

This bash script is an init script used to start and stop the Apache Ofbiz open source enterprise automation software. It sets various environment variables needed to run Ofbiz, such as the Java home and classpath locations. When starting Ofbiz, it checks if it is already running, removes log files, and runs the Java process in the background writing output to log files. When stopping Ofbiz, it attempts to shut it down gracefully and if needed will terminate processes forcefully.

Uploaded by

hillol001
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

File: /home/salauddin/Documents/scripts/ofbizd Page 1 of 2

#!/bin/bash -e
### BEGIN INIT INFO
# Provides: ofbiz
# Required-Start: $syslog $time $remote_fs
# Required-Stop: $syslog $time $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: start Apache Ofbiz
# Description: Debian init script for the Apache Ofbiz,
# the open source enterprise automation software
### END INIT INFO
set -e
######################################################################
#export JAVA_HOME
export JAVA_HOME=/home/admin/tools/jdk1.6.0_45
export CLASSPATH=/home/admin/tools/jdk1.6.0_45
#export CLASSPATH=$JAVA_HOME
#cd /home/newgenadmin/prottay
######################################################################
export JAVA_BINARY=$JAVA_HOME/bin/java
export JAVA=$JAVA_HOME/bin/java
OFBIZ_HOME=/home/newgenadmin/prottay
OFBIZ_LOG=$OFBIZ_HOME/runtime/logs/script.log
OFBIZ_OUT=/tmp/OfbizOut
#JAVA_VMOPTIONS="-Xms768M -Xmx1024M -Duser.language=en"
JAVA_ARGS="-jar ${OFBIZ_HOME}/ofbiz.jar"
#OFBIZ_USER=root
######################################################################
# shutdown settings
#ADMIN_PORT=10523
#ADMIN_KEY="InsertYourOwnKeyHered!"
# VM args
#ADMIN="-Dofbiz.admin.port=$ADMIN_PORT"
MEMIF="-Xms512M -Xmx1024M -XX:MaxPermSize=512m"
#MISC="-Duser.language=en"
VMARGS="$MEMIF"
#
ofbizprocs="pgrep java"
start() {
echo "Starting OFBiz: "
echo "Testing running OFBiz: "
if [ "$($ofbizprocs)" != "" ]; then
echo "OFBiz is already running..."
return 1
fi
# All clear
cd $OFBIZ_HOME
umask 007
/bin/rm -f $OFBIZ_OUT $OFBIZ_LOG
echo "Now really starting OFBiz: "
cd $OFBIZ_HOME && $JAVA_BINARY $VMARGS $JAVA_ARGS >$OFBIZ_OUT 2>>$OFBIZ_LOG&
echo "startup return value: " $?
return $?
}
# Stop OFBiz
stop() {
echo -n "Stopping OFBiz: "
if [ "$($ofbizprocs)" = "" ]; then
echo "OFBiz is not running..."
return 1
fi
# All clear
cd $OFBIZ_HOME
umask 007
cd $OFBIZ_HOME && $JAVA_BINARY $VMARGS $JAVA_ARGS -shutdown >$OFBIZ_OUT 2>>$OFBIZ_LOG&
sleep 15
if [ "$($ofbizprocs)" != "" ]; then
# Let's try to -TERM
File: /home/salauddin/Documents/scripts/ofbizd Page 2 of 2
/bin/kill -TERM "$($ofbizprocs)"
else
return 0
fi
sleep 10
if [ "$($ofbizprocs)" != "" ]; then
# Let's try it the hard way!
/bin/kill -9 "$($ofbizprocs)"
else
return 0
fi
sleep 10
if [ "$($ofbizprocs)" != "" ]; then
echo "Some processes could not be stopped:"
echo "$($ofbizprocs)"
echo "A possible solution is to try this command once more!"
return 1
else
return 0
fi
}
. /lib/lsb/init-functions
case "$1" in
start)
log_daemon_msg "Starting Apache Ofbiz" "ofbiz"
start
log_end_msg $?
;;
stop)
log_daemon_msg "Stopping deferred Apache Ofbiz" "ofbiz"
stop
log_end_msg $?
;;
force-reload|restart)
stop
start
;;
*)
echo "Usage: /etc/init.d/atd {start|stop|restart|force-reload}"
exit 1
;;
esac
exit 0

You might also like