add Apache mutex-file configuration
[contrib/pines/genasys.git] / templates / init / eg_opensrf
1 #!/bin/bash
2 ### BEGIN INIT INFO
3 # Provides:          opensrf
4 # Required-Start:    $local_fs $remote_fs $network $syslog apache2
5 # Required-Stop:     $local_fs $remote_fs $network $syslog 
6 # Default-Start:     2 3 4 5
7 # Default-Stop:      0 1 6
8 # X-Interactive:     true
9 # Short-Description: Start/stop OpenSRF Services
10 ### END INIT INFO
11 . /lib/lsb/init-functions
12
13 OPENILS_BASE="/openils"
14 OPENILS_CORE="${OPENILS_BASE}/conf/opensrf_core.xml"
15 SRU_LOG="${OPENILS_BASE}/var/log/sru.log"
16
17 PIDFILES="${OPENILS_BASE}/var/run"
18 SIP_CONF="${OPENILS_BASE}/conf/oils_sip.xml"
19
20 REP_LOCK="${OPENILS_BASE}/var/lock/reporter-LOCK"
21 REP_NAME="Clark Kent, waiting for trouble"
22
23 sru_name='simple2zoom'
24
25 export PATH=$PATH:${OPENILS_BASE}/bin
26
27 if [ $(whoami) != 'opensrf' ]; then
28  PERL5LIB='/openils/lib/perl5:$PERL5LIB';
29 fi;
30
31 start_opensrf() {
32         sleep 3
33         log_daemon_msg "Starting Evergreen OpenSRF:"
34         su - opensrf -c /bin/bash -c "PERL5LIB=${PERL5LIB}:${OPENILS_BASE}/lib/perl5 PATH=${PATH}:${OPENILS_BASE}/bin osrf_ctl.sh  -a start_all"
35 }
36
37 stop_opensrf() {
38         log_daemon_msg "Stopping Evergreen OpenSRF:"
39         su - opensrf -c /bin/bash -c "PERL5LIB=${PERL5LIB}:${OPENILS_BASE}/lib/perl5 PATH=${PATH}:${OPENILS_BASE}/bin osrf_ctl.sh  -a stop_all"
40         sleep 3
41         rm $PIDFILES/*.pid
42 }
43
44 autogen() {
45         echo "Running Autogen Update"
46         sudo -u opensrf /bin/bash -c "PERL5LIB=${PERL5LIB}:${OPENILS_BASE}/lib/perl5 PATH=${PATH}:${OPENILS_BASE}/bin autogen.sh -u -c ${OPENILS_CORE}"
47 }
48
49
50 case "$1" in
51     start)
52         start_opensrf
53     ;;
54     stop)
55         stop_opensrf
56     ;;
57     restart)
58         log_daemon_msg "Restarting Evergreen OpenSRF:"
59         stop_opensrf
60         sleep 2
61         start_opensrf
62     ;;
63     autogen)
64         autogen
65     ;;
66 *)
67         echo " * Usage: /etc/init.d/eg_opensrf {start|stop|restart|autogen}"
68         exit 1
69     ;;
70 esac;