]> git.evergreen-ils.org Git - contrib/pines/genasys.git/blob - templates/init/eg_opensrf
add Apache mutex-file configuration
[contrib/pines/genasys.git] / templates / init / eg_opensrf
1 #!/bin/bash
2 #TODO: properly attribute the original authors of this file
3 #TODO: add a 'status' command
4 #TODO: create an upstart job instead?
5
6 ### BEGIN INIT INFO
7 # Provides:          opensrf
8 # Required-Start:    $local_fs $remote_fs $network $syslog
9 # Required-Stop:     $local_fs $remote_fs $network $syslog 
10 # Default-Start:     2 3 4 5
11 # Default-Stop:      0 1 6
12 # X-Interactive:     true
13 # Short-Description: Start/stop OpenSRF Services
14 ### END INIT INFO
15 . /lib/lsb/init-functions
16
17 OPENILS_BASE="/openils"
18 OPENILS_CORE="${OPENILS_BASE}/conf/opensrf_core.xml"
19 SRU_LOG="${OPENILS_BASE}/var/log/sru.log"
20
21 PIDFILES="${OPENILS_BASE}/var/run"
22 SIP_CONF="${OPENILS_BASE}/conf/oils_sip.xml"
23
24 REP_LOCK="${OPENILS_BASE}/var/lock/reporter-LOCK"
25 REP_NAME="Clark Kent, waiting for trouble"
26
27 sru_name='simple2zoom'
28
29 export PATH=$PATH:${OPENILS_BASE}/bin
30
31 if [ $(whoami) != 'opensrf' ]; then
32  PERL5LIB='/openils/lib/perl5:$PERL5LIB';
33 fi;
34
35 start_opensrf() {
36         sleep 3
37         log_daemon_msg "Starting Evergreen OpenSRF:"
38         su - opensrf -c /bin/bash -c "PERL5LIB=${PERL5LIB}:${OPENILS_BASE}/lib/perl5 PATH=${PATH}:${OPENILS_BASE}/bin osrf_control --start-all"
39         sleep 2
40         if [ ! -e ${OPENILS_BASE}/var/web/eg_cache_hash ]
41         then
42                 if dpkg -l | grep "evergreen-ils" | grep "ii"
43                         then
44                         log_daemon_msg "Running Autogen...:"
45                         su - opensrf /bin/bash -c "PERL5LIB=${PERL5LIB}:${OPENILS_BASE}/lib/perl5 PATH=${PATH}:${OPENILS_BASE}/bin autogen.sh -u"
46                 fi
47         fi
48 }
49
50 stop_opensrf() {
51         log_daemon_msg "Stopping Evergreen OpenSRF:"
52         su - opensrf -c /bin/bash -c "PERL5LIB=${PERL5LIB}:${OPENILS_BASE}/lib/perl5 PATH=${PATH}:${OPENILS_BASE}/bin osrf_control --stop-all"
53         sleep 3
54         rm -f $PIDFILES/*.pid
55 }
56
57 autogen() {
58         echo "Running Autogen Update"
59         su - opensrf /bin/bash -c "PERL5LIB=${PERL5LIB}:${OPENILS_BASE}/lib/perl5 PATH=${PATH}:${OPENILS_BASE}/bin autogen.sh -u"
60 }
61
62
63 case "$1" in
64     start)
65         start_opensrf
66         /etc/init.d/apache2-websockets stop
67         /etc/init.d/apache2 restart
68         /etc/init.d/apache2-websockets start
69     ;;
70     stop)
71         stop_opensrf
72     ;;
73     restart)
74         /etc/init.d/apache2-websockets stop
75         /etc/init.d/apache2 stop
76         log_daemon_msg "Restarting Evergreen OpenSRF:"
77         stop_opensrf
78         sleep 2
79         start_opensrf
80         /etc/init.d/apache2-websockets start
81         /etc/init.d/apache2 start
82     ;;
83     autogen)
84         autogen
85     ;;
86 *)
87         echo " * Usage: /etc/init.d/eg_opensrf {start|stop|restart|autogen}"
88         exit 1
89     ;;
90 esac;