/[pdpsoft]/trunk/grid-mw-security/ees/setup/ees.init.d
ViewVC logotype

Annotation of /trunk/grid-mw-security/ees/setup/ees.init.d

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1852 - (hide annotations) (download) (as text)
Fri Jul 9 12:08:06 2010 UTC (11 years, 10 months ago) by aramv
File MIME type: text/x-dsrc
File size: 2890 byte(s)
Made error message shorter so it fits well
1 aramv 1842 #!/bin/sh
2     #
3     # ees Starting, stopping and restarting the ees daemon.
4     #
5     # Author: Aram Verstegen
6     #
7     # chkconfig: 2345 99 01
8     # description: Starts and stops EES daemon
9    
10    
11     prog="ees"
12 aramv 1851 fullprog="/tmp/build/glite/sbin/ees"
13     configfile="/tmp/build/glite/etc/ees.conf"
14     lockfile="/tmp/lock/subsys/ees"
15 aramv 1842 nonprivaccount="ees"
16    
17     # Source function library
18 aramv 1846 if [ -f /etc/redhat-release ]; then
19 aramv 1842 # Redhat-style
20     . /etc/rc.d/init.d/functions
21    
22 aramv 1851 start_ees_daemon="daemon --user $nonprivaccount $fullprog $configfile"
23 aramv 1846 elif [ -f /etc/debian_version ]; then
24 aramv 1842 # Debian-style
25     . /lib/lsb/init-functions
26     echo_success(){
27     echo success
28     }
29     echo_failure(){
30     echo failure
31     }
32 aramv 1848 start_ees_daemon="start-stop-daemon --start --chuid $nonprivaccount --exec $fullprog $configfile"
33 aramv 1846 elif [ -f /etc/SuSE-release ]; then
34 aramv 1842 # SUSE-style
35     . /etc/rc.status
36     echo_success(){
37     rc_reset
38     rc_status -v
39     }
40     echo_failure(){
41     rc_failure
42     rc_status -v
43     }
44 aramv 1848 start_ees_daemon="start-stop-daemon --start --chuid $nonprivaccount --exec $fullprog $configfile"
45 aramv 1842 else
46     echo_success(){
47     echo success
48     }
49     echo_failure(){
50     echo failure
51     }
52     echo -n "Warning! Unable to determine the correct daemon runner for your distribution."
53 aramv 1847 start_ees_daemon="exec $fullprog $configfile"
54 aramv 1842 fi
55    
56     start() {
57     echo -n "Starting EES: "
58     # Check if there should be an EES instance running
59     if [ -f $lockfile ]; then
60     eespid=`pidofproc $fullprog`
61     if [ -z "$eespid" ]; then
62 aramv 1848 echo -n "removing stale lockfile... "
63 aramv 1842 rm -f $lockfile
64     else
65     # EES already running
66 aramv 1852 echo -n "already running. "
67 aramv 1848 echo_failure
68 aramv 1850 echo
69 aramv 1842 exit $?
70     fi
71     fi
72     # Starting EES daemon now.
73 aramv 1847 ${start_ees_daemon} && touch $lockfile
74 aramv 1845 if [ $? -eq 0 ]; then
75 aramv 1848 echo_success
76 aramv 1845 else
77 aramv 1848 echo -n "EES failed to start. "
78 aramv 1845 echo_failure
79     fi
80 aramv 1849 echo
81 aramv 1842 }
82    
83     stop() {
84     # Stopping EES
85 aramv 1845 echo -n "Stopping EES: "
86 aramv 1842 if [ -f $lockfile ]; then
87     # Killing EES now.
88 aramv 1848 kill -TERM `pidofproc $fullprog`
89 aramv 1842 rm -rf $lockfile
90     echo_success
91     else
92     # No EES running, nothing to kill
93 aramv 1848 echo -n "no EES running. "
94 aramv 1845 echo_failure
95 aramv 1842 fi
96 aramv 1849 echo
97 aramv 1842 }
98    
99     restart(){
100 aramv 1850 echo -n "Restarting EES. "
101     eespid=`pidofproc $fullprog`
102     if [ -f $lockfile ]; then
103     kill -HUP $eespid
104     if [ $? -eq 0 ]; then
105     echo_success
106     fi
107     else
108     echo -n "EES not running. "
109     echo_failure
110     fi
111 aramv 1849 echo
112 aramv 1842 }
113    
114     # See how we are called
115     case "$1" in
116     start)
117     start
118     ;;
119     stop)
120     stop
121     ;;
122     restart)
123     restart
124     ;;
125     status)
126 aramv 1850 if [ -f $lockfile ]; then
127     echo "ees is running"
128     else
129     echo "ees is stopped"
130     fi
131 aramv 1842 ;;
132     *)
133     echo "Usage $0 {start|stop|restart|status}"
134     exit 1
135     esac
136    
137     exit 0

grid.support@nikhef.nl
ViewVC Help
Powered by ViewVC 1.1.28