From ddc63106734aa1c2debc5f83a74d51dea0f0a7d9 Mon Sep 17 00:00:00 2001 From: "Joe Atzberger (siptest" Date: Fri, 19 Jun 2009 19:32:41 -0500 Subject: [PATCH] Functional SIP run and shutdown scripts. Update example SIPconfig.xml Note the shutdown script is quick and dirty, and probably platform (debian) specific. Signed-off-by: Galen Charlton --- C4/SIP/SIPconfig.xml | 24 +++++++++++++----------- C4/SIP/sip_run.sh | 37 +++++++++++++++++++++++++++++++++++++ C4/SIP/sip_shutdown.sh | 19 +++++++++++++++++++ 3 files changed, 69 insertions(+), 11 deletions(-) create mode 100755 C4/SIP/sip_run.sh create mode 100755 C4/SIP/sip_shutdown.sh diff --git a/C4/SIP/SIPconfig.xml b/C4/SIP/SIPconfig.xml index a3800b5534..0e5f05ed31 100644 --- a/C4/SIP/SIPconfig.xml +++ b/C4/SIP/SIPconfig.xml @@ -1,5 +1,5 @@ - + @@ -36,37 +36,39 @@ delimiter="|" error-detect="enabled" institution="LPL" /> - - - - - + + - - - - - diff --git a/C4/SIP/sip_run.sh b/C4/SIP/sip_run.sh new file mode 100755 index 0000000000..587e323438 --- /dev/null +++ b/C4/SIP/sip_run.sh @@ -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 index 0000000000..07abbce3f1 --- /dev/null +++ b/C4/SIP/sip_shutdown.sh @@ -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; -- 2.39.5