From 6e2236db7ca0c4b385fd1c58ed69f40cb3b15814 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Fri, 5 Jun 2015 08:26:34 -0700 Subject: [PATCH] JBAS-712 ZOOM control script additions ./eg-zoom-control.sh [start|stop|status] Signed-off-by: Bill Erickson --- KCLS/admin-scripts/eg-zoom-control.sh | 58 +++++++++++++++++++++++++++++++++++ KCLS/utility-scripts/start-zoom.sh | 22 ------------- 2 files changed, 58 insertions(+), 22 deletions(-) create mode 100755 KCLS/admin-scripts/eg-zoom-control.sh delete mode 100755 KCLS/utility-scripts/start-zoom.sh diff --git a/KCLS/admin-scripts/eg-zoom-control.sh b/KCLS/admin-scripts/eg-zoom-control.sh new file mode 100755 index 0000000000..215ae2ddb6 --- /dev/null +++ b/KCLS/admin-scripts/eg-zoom-control.sh @@ -0,0 +1,58 @@ +#!/bin/bash +# Start the simple2zoom SRU/Z39.50 service +# Listens on localhost:2210 and this machine's FQDN +# Must be run with sudo / root, since it uses port 210 +set -eu +PUBLIC_HOST=$(hostname -f); +ZOOM_LOG=/openils/var/log/zoom-server.log +PID_FILE=/openils/var/run/zoom.pid + +function zoom_start { + + # create a backup of the log file + # NOTE: this needs rotating + [ -f $ZOOM_LOG ] && mv $ZOOM_LOG $ZOOM_LOG.$(date +%F); + + # create the file so we can safely chown it later + touch /openils/var/log/zoom-server.log + + /usr/bin/perl \ + -w /usr/bin/simple2zoom \ + -c /openils/conf/dgo.conf -- \ + -f /openils/conf/xml2marc-yaz.cfg \ + localhost:2210 $PUBLIC_HOST:210 >> "$ZOOM_LOG" 2>&1 & + + pid=$!; + echo $pid > $PID_FILE; + + chown opensrf:opensrf $ZOOM_LOG +} + +function zoom_stop { + if [ ! -f $PID_FILE ]; then + echo "ZOOM is not running" + return; + fi + pid=$(cat $PID_FILE); + echo "Stopping Zoom / Z39.50" + kill -s TERM $pid; + rm -f $PID_FILE; +} + +function zoom_status { + set +e + if [ "$(ps ax | grep simple2zoom | grep -v grep)" ]; then + echo "ZOOM is running" + fi + set -e +} + +ACTION=$1 + +case $ACTION in + "start") zoom_start;; + "stop") zoom_stop;; + "status") zoom_status;; + *) echo "$0 [start|stop|status]";; +esac; + diff --git a/KCLS/utility-scripts/start-zoom.sh b/KCLS/utility-scripts/start-zoom.sh deleted file mode 100755 index 19cbb87e85..0000000000 --- a/KCLS/utility-scripts/start-zoom.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash -# Start the simple2zoom SRU/Z39.50 service -# Listens on localhost:2210 and this machine's FQDN -# Must be run with sudo / root, since it uses port 210 -set -eu -PUBLIC_HOST=$(hostname -f); -ZOOM_LOG=/openils/var/log/zoom-server.log - -# create a backup of the log file -# NOTE: this needs rotating -[ -f $ZOOM_LOG ] && mv $ZOOM_LOG $ZOOM_LOG.$(date +%F); - -# create the file so we can safely chown it later -touch /openils/var/log/zoom-server.log - -nohup /usr/bin/perl \ - -w /usr/bin/simple2zoom \ - -c /openils/conf/dgo.conf -- \ - -f /openils/conf/xml2marc-yaz.cfg \ - localhost:2210 $PUBLIC_HOST:210 > $ZOOM_LOG & - -chown opensrf:opensrf $ZOOM_LOG -- 2.11.0