JBAS-712 marc_stream_importer.pl control script
authorBill Erickson <berickxx@gmail.com>
Fri, 5 Jun 2015 16:06:20 +0000 (12:06 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
sudo ./eg-marc-stream-control.sh [start <password> | status | stop]

KCLS/admin-scripts/eg-marc-stream-control.sh [new file with mode: 0755]

diff --git a/KCLS/admin-scripts/eg-marc-stream-control.sh b/KCLS/admin-scripts/eg-marc-stream-control.sh
new file mode 100755 (executable)
index 0000000..d55482d
--- /dev/null
@@ -0,0 +1,49 @@
+#!/bin/bash
+# Control marc_stream_importer.pl
+# sudo ./eg-marc-stream-control.sh [start <staff-password>|stop|status]
+
+PID_FILE=/openils/var/run/marc_stream_importer.pid
+ACTION=$1
+STAFF_PASSWORD=$2
+STAFF_USER=admin
+BIB_QUEUE=14
+BIB_MERGE_PROFILE=1
+
+# marc_stream_importer.pl creates the PID file for us
+function marc_stream_start {
+    if [ -z "$STAFF_PASSWORD" ]; then
+        echo "$0 start <staff-password>"
+        return
+    fi
+    cd /openils/bin
+    sudo -u opensrf ./marc_stream_importer.pl \
+        --merge-profile $BIB_MERGE_PROFILE --user $STAFF_USER \
+        --password $STAFF_PASSWORD --queue $BIB_QUEUE >> /dev/null 2>&1 &
+}
+
+function marc_stream_stop {
+    if [ ! -f $PID_FILE ]; then
+        echo "marc_stream_importer is not running"
+        return;
+    fi
+    cd /openils/bin
+    sudo -u opensrf kill $(cat $PID_FILE)
+    sudo rm -f $PID_FILE
+}
+
+function marc_stream_status {
+    set +e
+    if [ "$(ps ax | grep marc_stream | grep -v grep)" ]; then
+        echo "marc_stream_importer is running"
+    fi
+    set -e
+}
+
+
+case $ACTION in
+    "start")  marc_stream_start;;
+    "stop")   marc_stream_stop;;
+    "status") marc_stream_status;;
+       *) echo "$0 [start <password>|stop|status]";;
+esac;
+