removed the deprecated rest_gateway config; added comment on router name changes
[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         i=$(whoami) && [ "$i" != "opensrf" ] && echo "Must be run as user 'opensrf'.  Exiting..." && exit;
16
17         case $1 in 
18         
19                 "start")
20                         [ -z "$2" ] && usage;
21                         perl -MOpenSRF::System="$2" -e 'OpenSRF::System->bootstrap()' & 
22                         sleep 5;
23                         $0 status;
24                         echo;
25                         ;;
26         
27                 "startprofile")
28                         [ -z "$2" ] && usage;
29                         OPENSRF_PROFILE=1 perl -MOpenSRF::System="$2" -e 'OpenSRF::System->bootstrap()' & 
30                         sleep 5;
31                         $0 status;
32                         echo;
33                         ;;
34         
35                 "stop")
36                         PID=$(ps ax | grep -i "opensrf system" | grep -v grep | awk '{print $1}');
37
38                         if [ -z "$PID" ]; then
39                                 echo "OpenSRF System is not running";
40                                 exit;
41
42                         else
43                                 echo "Killing System...$PID";
44                                 kill -s INT $PID;
45                         fi
46
47                         echo "Done";
48                         ;;
49         
50                 "status")
51                         PID=$(ps ax | grep -i "opensrf system" | grep -v grep | awk '{print $1}');
52                         if [ -z "$PID" ]; then
53                                 echo "OpenSRF System is not running";
54                                 exit 0;
55                         fi
56                         echo "OpenSRF System is running";
57                         exit 1;
58                         ;;
59         
60                 "restart")
61                         [ -z "$2" ] && usage;
62                         $0 stop;
63                         $0 start $2;
64                         ;;
65                 *)
66                         usage;
67                         ;;
68         esac
69 }
70
71 startSystem $*;
72         
73