5449094525f9059918cc3c3f7a8eeba560835f0c
[OpenSRF.git] / bin / opensrf_ctl
1 #!/bin/bash
2
3
4 #  Simple rc script for controlling the system
5 #  Only works on linux because of 'ps' syntax
6 #
7
8 function usage {
9         echo "usage: $0 [start|stop|restart|status] <boostrap_config (on start and restart)>";
10         exit;
11 }
12
13 function startSystem {
14
15         case $1 in 
16         
17                 "start")
18                         [ -z "$2" ] && usage;
19                         perl -MOpenSRF::System="$2" -e 'OpenSRF::System->bootstrap()' & 
20                         sleep 5;
21                         $0 status;
22                         echo;
23                         ;;
24         
25                 "startprofile")
26                         [ -z "$2" ] && usage;
27                         OPENSRF_PROFILE=1 perl -MOpenSRF::System="$2" -e 'OpenSRF::System->bootstrap()' & 
28                         sleep 5;
29                         $0 status;
30                         echo;
31                         ;;
32         
33                 "stop")
34                         PID=$(ps ax | grep "[0-9] System$" | awk '{print $1}');
35                         if [ -z "$PID" ]; then
36                                 echo "OpenSRF System is not running";
37                                 exit;
38                         fi
39                         echo "Killing System...$PID";
40                         kill -s INT $PID;
41                         echo "Done";
42                         ;;
43         
44                 "status")
45                         PID=$(ps ax | grep "[0-9] System$" | awk '{print $1}');
46                         if [ -z "$PID" ]; then
47                                 echo "OpenSRF System is not running";
48                                 exit 0;
49                         fi
50                         echo "OpenSRF System is running";
51                         exit 1;
52                         ;;
53         
54                 "restart")
55                         [ -z "$2" ] && usage;
56                         $0 stop;
57                         $0 start $2;
58                         ;;
59                 *)
60                         usage;
61                         ;;
62         esac
63 }
64
65 startSystem $*;
66         
67