JBAS-885 eg-updator util and sip controls
authorBill Erickson <berickxx@gmail.com>
Fri, 18 Sep 2015 18:36:24 +0000 (14:36 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
Added support for the following commands:

start-util
stop-util
start-sip
stop-sip

"util" includes z39, connexion, and hold targeter.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
KCLS/admin-scripts/eg-updater.sh
KCLS/admin-scripts/eg-zoom-control.sh

index 1dfd4b6..493e671 100755 (executable)
@@ -30,6 +30,7 @@ CLIENT_SERIES_ID=""
 GIT_REMOTE="kcls"
 REBUILD=""
 ACTIONS=""
+ADMIN_PASS=""
 
 # if the script exits early, SUCCESS will be left as 0, 
 # which is our sign to warn the user.
@@ -60,12 +61,16 @@ function usage {
                 detach
                 stop-apache
                 stop-eg
+                stop-util (z39, connexion, hold targeter)
+                stop-sip
                 update-eg
                 deploy-eg
                 update-web
                 build-staff
                 start-eg
                 start-apache
+                start-util
+                start-sip
                 attach
                 stop-all (detach,stop-apache,stop-eg) 
                 deploy-all (update-eg,deploy-eg)
@@ -114,6 +119,9 @@ function usage {
             -d  Number of seconds to wait after detach.  The default is
                 $DETACH_SLEEP.
 
+            -w  Admin password.  Needed for starting utility services,
+                specifically the marc_stream_importer (for Connexion).
+
 USAGE
 trap - EXIT
 exit;
@@ -477,11 +485,76 @@ function start_services {
     sleep $START_SLEEP;
 }
 
+function stop_util {
+    announce "Stopping utility services"
+
+    announce "Stopping hold targeter"
+    [ -f /tmp/hold_targeter-LOCK ] && \
+        sudo kill $(cat /tmp/hold_targeter-LOCK)
+
+    cd $EVERGREEN_BASE/KCLS/admin-scripts;
+
+    announce "Stopping Z39.50"
+    sudo ./eg-zoom-control.sh stop
+
+    announce "Stopping Connexion"
+    sudo ./eg-marc-stream-control.sh stop
+
+    cd $EVERGREEN_BASE;
+}
+
+function start_util {
+    announce "Starting utility services"
+
+    announce "Removing hold targeter lock file"
+    sudo rm -f /tmp/hold_targeter-LOCK
+
+    cd $EVERGREEN_BASE/KCLS/admin-scripts;
+
+    announce "Starting Z39.50"
+    sudo ./eg-zoom-control.sh start
+
+    if [ -n "$ADMIN_PASS" ]; then
+        announce "Starting Connextion"
+        sudo ./eg-marc-stream-control.sh start "$ADMIN_PASS"
+    else 
+        announce "Starting Connexion requires the admin password"
+        announce "Provide password via -w or start manually:"
+        announce "sudo ./eg-marc-stream-control.sh start <pass>"
+    fi
+
+    cd $EVERGREEN_BASE;
+}
+
+function start_sip {
+    OSRF_LOG_CLIENT=1 $OSRF /openils/bin/oils_ctl.sh \
+        -a start_sip -l /openils/var/log/sip_err.log
+}
+
+function stop_sip {
+    announce "Stopping SIP"
+    $OSRF /openils/bin/oils_ctl.sh -a stop_sip
+
+    if [ -f /openils/var/log/sip_err.log ]; then
+        # move the log file over so we can remove it later w/o
+        # pulling it out from under a running SIP instance.
+
+        announce "Renaming old SIP error log file"
+
+        # include the time (w/ seconds) to ensure a new log file
+        # name even if there are multiple restarts in a short period.
+        LDATE=$(date +'%FT%T')
+        $OSRF mv /openils/var/log/sip_err.log \
+            /openils/var/log/sip_err.$LDATE.log
+    fi
+}
+
+
 # -- script starts here --
 
 trap on_exit EXIT;
 
-while getopts "a:t:b:r:s:i:f:d:pchl" opt; do
+while getopts "a:t:b:r:s:i:f:d:pchlw:" opt; do
     case $opt in
         a) ACTIONS="$OPTARG";;
         b) GIT_BRANCH="$OPTARG";;
@@ -494,6 +567,7 @@ while getopts "a:t:b:r:s:i:f:d:pchl" opt; do
         r) GIT_REMOTE="$OPTARG";;
         s) CLIENT_BUILD_ID="$OPTARG";;
         t) GIT_TAG="$OPTARG";;
+        w) ADMIN_PASS="$OPTARG";;
         h) usage;
     esac
 done;
@@ -528,6 +602,15 @@ if [[ "$ACTIONS" =~ "stop-apache" ]]; then
     fi
 fi
 
+if [[ "$ACTIONS" =~ "stop-util" ]]; then
+    stop_util;
+fi
+
+if [[ "$ACTIONS" =~ "stop-sip" ]]; then
+    stop_sip;
+fi
+
+
 if [[ "$ACTIONS" =~ "stop-eg" ]]; then
     announce "Stopping services"
     $OSRF /openils/bin/osrf_control --localhost \
@@ -566,6 +649,14 @@ if [[ "$ACTIONS" =~ "start-apache" ]]; then
     sudo service apache2 start > /dev/null
 fi
 
+if [[ "$ACTIONS" =~ "start-util" ]]; then
+    start_util;
+fi
+
+if [[ "$ACTIONS" =~ "start-sip" ]]; then
+    start_sip;
+fi
+
 if [[ "$ACTIONS" =~ "attach" ]]; then
     if [ -f $PING_FILE- ]; then
         if [[ "$ACTIONS" =~ "start-apache" ]]; then
index 215ae2d..20aa985 100755 (executable)
@@ -35,7 +35,9 @@ function zoom_stop {
     fi
     pid=$(cat $PID_FILE);
     echo "Stopping Zoom / Z39.50"
-    kill -s TERM $pid;
+    set +e
+    kill -s TERM $pid 2> /dev/null
+    set -e
     rm -f $PID_FILE;
 }