6 SIP_DIR="/opt/SIP/SIPServer";
8 # ---------------------------------------------------------------------------
9 # Make sure we're running as the correct user
10 # ---------------------------------------------------------------------------
11 [ $(whoami) != 'opensrf' ] && echo 'Must run as user "opensrf"' && exit;
16 echo "usage: $0 -d <pid_dir> -s <sip_config> -a <action>";
18 echo "Actions include:"
21 echo -e "\trestart_sip"
27 # ---------------------------------------------------------------------------
28 # Load the command line options and set the global vars
29 # ---------------------------------------------------------------------------
30 while getopts "a:d:s:" flag; do
32 "a") OPT_ACTION="$OPTARG";;
33 "s") OPT_SIP_CONFIG="$OPTARG";;
34 "d") OPT_PID_DIR="$OPTARG";;
40 [ -z "$OPT_PID_DIR" ] && OPT_PID_DIR=/tmp;
41 [ -z "$OPT_ACTION" ] && usage;
43 PID_SIP="$OPT_PID_DIR/oils_sip.pid";
46 # ---------------------------------------------------------------------------
47 # Utility code for checking the PID files
48 # ---------------------------------------------------------------------------
55 if [ $action == "start" ]; then
57 if [ -e $pidfile ]; then
59 echo "$item already started : $pid";
62 echo "Starting $item";
65 if [ $action == "stop" ]; then
67 if [ ! -e $pidfile ]; then
68 echo "$item not running";
73 echo "Stopping $item : $pid";
83 # ---------------------------------------------------------------------------
84 # Start / Stop functions
85 # ---------------------------------------------------------------------------
89 do_action "start" $PID_SIP "OILS SIP Server";
92 nohup perl SIPServer.pm "$OPT_SIP_CONFIG" &
101 do_action "stop" $PID_SIP "OILS SIP Server";
107 # ---------------------------------------------------------------------------
108 # Do the requested action
109 # ---------------------------------------------------------------------------
111 "start_sip") start_sip;;
112 "stop_sip") stop_sip;;
113 "restart_sip") stop_sip; start_sip;;