2 # --------------------------------------------------------------------
3 # Copyright (C) 2005 Georgia Public Library Service
4 # Bill Erickson <highfalutin@gmail.com>
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; either version 2
9 # of the License, or (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 # --------------------------------------------------------------------
18 # --------------------------------------------------------------------------
19 # Utility script for starting the jserver (the opensrf jabber server), the
20 # opensrf router, and opensrf proper.
21 # see vars below for ways to alter the behavior and directory locations
22 # --------------------------------------------------------------------------
26 # --------------------------------------------------------------------------
28 # --------------------------------------------------------------------------
30 ETCDIR="$PREFIX/conf"; # config files are found here
31 LOGDIR="$PREFIX/var/log"; # logs go here
32 BINDIR="$PREFIX/bin"; # executables are found here
33 BOOTSTRAP="$ETCDIR/bootstrap.conf"; # opensrf config is here
35 # should these be started? set to "" or nothing to disable them
41 #JSERVERSOCK="$PREFIX/var/sock/jserver.sock"; # jabber server socket file
42 #JSERVERLOG="$LOGDIR/jserver.log" # jabber server log
43 JSERVERPORT=5222; # jabber server port
44 #JSERVERLEVEL=3; # can be 1-4, 4 is the highest
45 #JSERVERIP="*"; # can be "*" or a specific local IP address
46 # --------------------------------------------------------------------------
47 # --------------------------------------------------------------------------
50 export LD_LIBRARY_PATH="$PREFIX/lib:$LD_LIBRARY_PATH";
51 export PERL5LIB="$PREFIX/lib/perl5:$PERL5LIB";
52 export PATH="$PREFIX/bin:$PATH";
55 function fail { echo "$0 exited: $*"; exit 99; }
57 function usage { echo "$0 [ start | stop | restart ]"; }
60 function startJserver {
62 ACTIVE=$(netstat -an | grep $JSERVERPORT);
64 if [ ! -z "$ACTIVE" ]; then
66 echo "Port $JSERVERPORT is busy. Waiting 60 seconds for the port to clear up..."
68 for ((i=0; i!= 60; i++)) {
69 ACTIVE=$(netstat -an | grep $JSERVERPORT);
70 [ -z "$ACTIVE" ] && break;
75 ACTIVE=$(netstat -an | grep $JSERVERPORT);
76 [ ! -z "$ACTIVE" ] && fail "Port $JSERVERPORT is busy...exiting";
79 "$BINDIR/$JSERVERBIN" "$ETCDIR/opensrf_core.xml" "chopchop";
83 function startRouter {
84 "$BINDIR/opensrf_router" "$ETCDIR/opensrf_core.xml" "router"
87 function startOpenSRF {
89 "$BINDIR/opensrf_ctl" start "$BOOTSTRAP";
91 if [ ! -z "$OPENSRFC" ]; then
92 echo "Starting OpenSRF-C...";
93 # localhost will need to be changed...
94 "$BINDIR/opensrf-c" $(hostname -f) "$ETCDIR//opensrf_core.xml" "opensrf"
95 echo "OpenSRF-C started OK";
102 i=$(whoami) && [ "$i" != "opensrf" ] && echo "Must be run as user 'opensrf'. Exiting..." && exit;
104 if [ ! -z "$JSERVER" ]; then
105 echo "Starting Chop Chop, Jabber (jserver-c)...";
107 echo "Chop Chop started OK";
112 if [ ! -z "$ROUTER" ]; then
113 echo "Starting router...";
115 echo "Router started OK";
120 if [ ! -z "$OPENSRF" ]; then
121 echo "Starting OpenSRF...";
123 echo "OpenSRF started OK";
132 echo "Stopping OpenSRF...";
133 "$BINDIR/opensrf_ctl" stop;
134 killall -9 opensrf-c;
137 echo "Stopping The Router...";
138 killall -9 "opensrf_router"
142 echo "Stopping Chop Chop...";
149 [ "$1" = "stop" ] && stopMe && exit;
150 [ "$1" = "restart" ] && stopMe && makeMeGo && exit;
151 [ "$1" = "start" ] && makeMeGo && exit;