]> git.evergreen-ils.org Git - Evergreen.git/blob - OpenSRF/bin/opensrf_ctl
98ac929f681c21d38152902a7aceaba1304bb1b4
[Evergreen.git] / OpenSRF / 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 usage() {
9         echo "usage: system.sh [start|stop|restart|status] <boostrap_config (on start and restart)>";
10 }
11
12
13 case $1 in 
14         "start")
15                 if [ -z $2 ]; then
16                         usage;
17                         exit;
18                 fi              
19                 perl -MOpenSRF::System="$2" -e 'OpenSRF::System->bootstrap()' & 
20                 sleep 2;
21                 $0 status;
22                 echo;
23                 ;;
24         "startprofile")
25                 if [ -z $2 ]; then
26                         usage;
27                         exit;
28                 fi              
29                 OPENSRF_PROFILE=1 perl -MOpenSRF::System="$2" -e 'OpenSRF::System->bootstrap()' & 
30                 sleep 2;
31                 $0 status;
32                 echo;
33                 ;;
34         "stop")
35                 PID=$(ps ax | grep "[0-9] System$" | awk '{print $1}');
36                 if [ -z $PID ]; then
37                         echo "OpenSRF System is not running";
38                         exit;
39                 fi
40                 echo "Killing System...$PID";
41                 kill -s INT $PID;
42                 echo "Done";
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         "restart")
54                 if [ -z $2 ]; then
55                         usage;
56                         exit;
57                 fi              
58                 $0 stop;
59                 $0 start $2;
60                 ;;
61         *)
62                 usage;
63                 ;;
64 esac
65
66