From 173dd6a1d0b1850b4870cc51b8d888f6a8041022 Mon Sep 17 00:00:00 2001 From: Liam Whalen Date: Fri, 7 Mar 2014 16:01:33 -0800 Subject: [PATCH] System V Evergreen start/stop/status These scripts add the ability to start and stop Evergreen via the command 'service openils start' and 'service openils stop'. To do this, place ubuntu-precise/openils in /etc/init.d/ and make sure it has 755 for its permissions. Then, move ubuntu-precies/start-openils and ubunut-precies/stop-openils to /usr/local/sbin/ and make sure they have 755 as well. Finally, give the openils service runlevel priorites. You can do this with the following command: 'update-rd.d openils defaults 88 13' I have tested this with master on Ubunut 12.04. It is also working, with modifications on Sitka's 2.4 systems. Signed-off-by: Liam Whalen --- Open-ILS/examples/ubuntu-precise/openils | 88 ++++++++++++++++++++++++++ Open-ILS/examples/ubuntu-precise/start-openils | 5 ++ Open-ILS/examples/ubuntu-precise/stop-openils | 5 ++ 3 files changed, 98 insertions(+) create mode 100755 Open-ILS/examples/ubuntu-precise/openils create mode 100755 Open-ILS/examples/ubuntu-precise/start-openils create mode 100755 Open-ILS/examples/ubuntu-precise/stop-openils diff --git a/Open-ILS/examples/ubuntu-precise/openils b/Open-ILS/examples/ubuntu-precise/openils new file mode 100755 index 0000000000..ffa3d08e93 --- /dev/null +++ b/Open-ILS/examples/ubuntu-precise/openils @@ -0,0 +1,88 @@ +#!/bin/sh + +### BEGIN INIT INFO +# Provides: OpenSRF/Evergreen +# Required-Start: $local_fs $remote_fs $network $syslog $named +# Required-Stop: $local_fs $remote_fs $network $syslog $named +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Start/Stop OpenSRF +### END INIT INFO + +DAEMON=/openils/bin/osrf_ctl.sh +OPENILS_PID_DIR=/openils/var/run/opensrf/ + +test -x $DAEMON || exit 5 + +COUNT=0 + +case $1 in + start) + while [ $COUNT -ne 3 ] + do + EJABBERD_STATUS=`ejabberdctl status` + if [ `echo $EJABBERD_STATUS | grep -e "status: started" | wc -l` -eq 1 ] + then + echo "ejabberd status: $EJABBERD_STATUS" + #stop apache + #We are not checking to see if apache is running before stopping it + #because it is not harmful to stop apache when it is not running. + #However, if the speed of starting openils is ever an issue then + #we should add a check to see if apache is running before stopping it + service apache2 stop + sleep 2 + rm -f /srv/openils/var/run/opensrf/*.pid + su -c '/usr/local/sbin/start-openils' opensrf + sleep 2 + #start apache + service apache2 start + break + fi + sleep 5 + COUNT=`expr $COUNT + 1` + done + ;; + stop) + #we do not have to stop apache before stopping openils + su -c '/usr/local/sbin/stop-openils' opensrf + ;; + restart|force-reload) + $0 stop && sleep 2 && $0 start + ;; + try-restart) + if $0 status >/dev/null; then + $0 restart + else + exit 0 + fi + ;; + reload) + exit 3 + ;; + status) + echo "Status of openils" + LIST_OF_OPENILS_PIDS=`ls $OPENILS_PID_DIR`; + for openils_pid_file in $LIST_OF_OPENILS_PIDS + do + #check that the pid is running + PID=`cat $OPENILS_PID_DIR$openils_pid_file` + EVERYTHING_RUNNING=1; + if [ -n "$PID" ]; then + echo "$openils_pid_file is running (pid $PID)." + else + echo "$openils_pid_file is NOT running." + $EVERYTHING_RUNNING=0 + fi + done + + if [ $EVERYTHING_RUNNING -eq 1 ]; then + exit 0 + else + exit 1 + fi + ;; + *) + echo "Usage: $0 {start|stop|restart|try-restart|force-reload|status}" + exit 2 + ;; +esac diff --git a/Open-ILS/examples/ubuntu-precise/start-openils b/Open-ILS/examples/ubuntu-precise/start-openils new file mode 100755 index 0000000000..a888efa9b5 --- /dev/null +++ b/Open-ILS/examples/ubuntu-precise/start-openils @@ -0,0 +1,5 @@ +#!/bin/bash +export PATH=/openils/bin:$PATH +export PERL5LIB=/usr/local/share/perl:$PERL5LIB +/openils/bin/osrf_ctl.sh -l -a start_all +exit 0 diff --git a/Open-ILS/examples/ubuntu-precise/stop-openils b/Open-ILS/examples/ubuntu-precise/stop-openils new file mode 100755 index 0000000000..649d535259 --- /dev/null +++ b/Open-ILS/examples/ubuntu-precise/stop-openils @@ -0,0 +1,5 @@ +#!/bin/bash +export PATH=/openils/bin:$PATH +export PERL5LIB=/usr/local/share/perl:$PERL5LIB +/openils/bin/osrf_ctl.sh -l -a stop_all +exit 0 -- 2.11.0