--- /dev/null
+#!/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;
+