Functional SIP run and shutdown scripts. Update example SIPconfig.xml
authorJoe Atzberger (siptest <atz4sip@arwen.metavore.com>
Sat, 20 Jun 2009 00:32:41 +0000 (19:32 -0500)
committerGalen Charlton <galen.charlton@liblime.com>
Wed, 24 Jun 2009 14:00:50 +0000 (09:00 -0500)
Note the shutdown script is quick and dirty, and probably
platform (debian) specific.

Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
C4/SIP/SIPconfig.xml
C4/SIP/sip_run.sh [new file with mode: 0755]
C4/SIP/sip_shutdown.sh [new file with mode: 0755]

index a3800b5..0e5f05e 100644 (file)
@@ -1,5 +1,5 @@
 <acsconfig xmlns="http://openncip.org/acs-config/1.0/">
-<!-- FIXME: above address gets nothing? -->
+<!-- above address gets nothing, it's just a namespace -->
   <error-detect enabled="true" />
 
 <!-- Set Net::Server::PreFork runtime parameters -->
              delimiter="|" error-detect="enabled" institution="LPL" />
   </accounts>
 
-<!-- Institution tags will hold stuff used to interface to -->
-<!-- the rest of the ILS: authentication parameters, etc.  I -->
-<!-- don't know what yet, so it'll just be blank.  But there -->
-<!-- needs to be one institution stanza for each institution -->
-<!-- named in the accounts above. -->
+<!--
+Institution tags are for enabled branches.  There needs to be one
+institution stanza for each institution named in the accounts above.
+The implementation attribute is actually used to find the code to run,
+in our case "ILS".
+-->
+
 <institutions>
     <institution id="MAIN" implementation="ILS" parms="">
-          <policy checkin="true" renewal="true"
+          <policy checkin="true" renewal="true" checkout="true"
                  status_update="false" offline="false"
                  timeout="100"
                  retries="5" />
     </institution>
     <institution id="CPL" implementation="ILS" parms="">
-          <policy checkin="true" renewal="true"
+          <policy checkin="true" renewal="true" checkout="true"
                  status_update="false" offline="false"
                  timeout="25"
                  retries="5" />
     </institution>
     <institution id="kohalibrary" implementation="ILS" parms="">
-          <policy checkin="true" renewal="false"
+          <policy checkin="true" renewal="false" checkout="true"
                  status_update="false" offline="false"
                  timeout="100"
                  retries="5" />
     </institution>
     <institution id="kohalibrary2" implementation="ILS" parms="">
-          <policy checkin="true" renewal="false"
+          <policy checkin="true" renewal="false" checkout="true"
                  timeout="100"
                  retries="3" />
     </institution>
     <institution id="LPL" implementation="ILS">
-          <policy checkin="true" renewal="false"
+          <policy checkin="true" renewal="false" checkout="true"
                  timeout="100"
                  retries="5" />
     </institution>
diff --git a/C4/SIP/sip_run.sh b/C4/SIP/sip_run.sh
new file mode 100755 (executable)
index 0000000..587e323
--- /dev/null
@@ -0,0 +1,37 @@
+#!/bin/bash
+# 
+# A sample script for starting SIP.  
+# You probably want to specify new log destinations.
+#
+# Takes 3 optional arguments:
+# ~ SIPconfig.xml file to use
+# ~ file for STDOUT, default ~/sip.out
+# ~ file for STDERR, default ~/sip.err
+#
+# The STDOUT and STDERR files are only for the SIPServer process itself.
+# Actual SIP communication and transaction logs are handled by Syslog.
+#
+# Examples:
+#   sip_run.sh /path/to/SIPconfig.xml
+#   sip_run.sh ~/my_sip/SIPconfig.xml sip_out.log sip_err.log
+
+
+for x in HOME PERL5LIB KOHA_CONF ; do
+       echo $x=${!x}
+       if [ -z ${!x} ] ; then 
+               echo ERROR: $x not defined;
+               exit 1;
+       fi;
+done;
+unset x;
+cd $PERL5LIB/C4/SIP;
+echo;
+echo Running from `pwd`;
+
+sipconfig=${1:-`pwd`/SIPconfig.xml};
+outfile=${2:-$HOME/sip.out};
+errfile=${3:-$HOME/sip.err};
+
+echo "Calling (backgrounded):";
+echo "perl -I./ ./SIPServer.pm $sipconfig >>$outfile 2>>$errfile";
+perl -I./ ./SIPServer.pm $sipconfig >>$outfile 2>>$errfile &
diff --git a/C4/SIP/sip_shutdown.sh b/C4/SIP/sip_shutdown.sh
new file mode 100755 (executable)
index 0000000..07abbce
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+. $HOME/.bash_profile
+
+# this is brittle: the primary server must have the lowest PPID
+# this is brittle: ps behavior is very platform-specific, only tested on Debian Etch
+
+target="SIPServer";
+PROCPID=$(ps x -o pid,ppid,args --sort ppid | grep "$target" | grep -v grep | head -1 | awk '{print $1}');
+
+if [ ! $PROCPID ] ; then
+    echo "No processes found for $target";
+    exit;
+fi
+
+echo "SIP Processes for this user ($USER):";
+ps x -o pid,ppid,args --sort ppid | grep "$target" | grep -v grep ;
+echo "Killing process #$PROCPID";
+kill $PROCPID;