~upstart-devel/upstart/upstart-jobs

« back to all changes in this revision

Viewing changes to utopic/etc/init.d/openhpid

  • Committer: Dimitri John Ledkov
  • Date: 2014-11-19 12:58:41 UTC
  • Revision ID: dimitri.j.ledkov@intel.com-20141119125841-98dr37roy8dvcv3b
auto update

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#! /bin/sh
2
 
#
3
 
### BEGIN INIT INFO
4
 
# Provides:          openhpid
5
 
# Required-Start:    $network $remote_fs $syslog
6
 
# Required-Stop:     $network $remote_fs $syslog
7
 
# Should-Start:      $named
8
 
# Should-Stop:       $named
9
 
# Default-Start:     2 3 4 5
10
 
# Default-Stop:      0 1 6
11
 
# Short-Description: Start OpenHPI daemon at boot time
12
 
# Description:       Enable OpenHPI service which is provided by openhpid.
13
 
### END INIT INFO
14
 
#
15
 
# openhpid.sh    Start/Stop the openhpi daemon.
16
 
#
17
 
# description: openhpid is standard UNIX program which uses the OpenHPI \
18
 
#              APIs and provides a standard internet server to access those \
19
 
#              APIs for client programs.
20
 
# processname: openhpid
21
 
# config: the standard openhpi conf file specified on the command line or the env.
22
 
# pidfile: /var/run/openhpid.pid
23
 
24
 
# Author(s):
25
 
#       W. David Ashley <dashley@us.ibm.com>
26
 
#       Daniel de Araujo <ddearauj@us.ibm.com>
27
 
 
28
 
# Source function library.
29
 
PATH=/sbin:/bin:/usr/sbin:/usr/bin
30
 
prog="openhpid"
31
 
 
32
 
# If the openhpid executable is not available, we can't do any of this
33
 
test -f /usr/sbin/openhpid || exit 0
34
 
 
35
 
# Determine whether the lsb package is installed
36
 
# If it is, determine which lsb is installed:
37
 
# redhat, suse, or standard lsb
38
 
 
39
 
if test -f /etc/init.d/functions
40
 
then
41
 
   lsbtype="rh"
42
 
   . /etc/init.d/functions
43
 
elif test -f /etc/rc.status
44
 
then
45
 
   lsbtype="suse"
46
 
   . /etc/rc.status
47
 
elif test -f /lib/lsb/init-functions
48
 
then
49
 
   lsbtype="lsb"
50
 
   . /lib/lsb/init-functions
51
 
elif test -f /etc/gentoo-release
52
 
then
53
 
   lsbtype="gentoo"
54
 
   . /sbin/functions.sh
55
 
else
56
 
   lsbtype="nolsb"
57
 
fi
58
 
 
59
 
print_outcome()
60
 
{
61
 
   
62
 
        case "${lsbtype}" in
63
 
      
64
 
                rh)
65
 
                        echo
66
 
                        [ "$?" -eq 0 ]
67
 
                        ;;
68
 
 
69
 
                suse)
70
 
                        rc_status -v
71
 
                        ;;
72
 
 
73
 
                lsb)
74
 
                        if test "$?" -eq 0
75
 
                        then
76
 
                                log_success_msg "success"
77
 
                        else
78
 
                                log_failure_msg "failed"
79
 
                        fi
80
 
                        ;;
81
 
                
82
 
                gentoo)
83
 
                        eend $?
84
 
                        ;;
85
 
   
86
 
                nolsb)
87
 
                        if test "$?" -eq 0
88
 
                        then
89
 
                                echo " ... success"
90
 
                        fi
91
 
                        if test "$?" -ne 0
92
 
                        then
93
 
                                echo " ... failed"
94
 
                        fi
95
 
                        ;;
96
 
        esac
97
 
}
98
 
 
99
 
start() {       
100
 
        case "${lsbtype}" in
101
 
                
102
 
                rh) 
103
 
                        echo -n "Starting $prog: "
104
 
                        daemon /usr/sbin/openhpid -c /etc/openhpi/openhpi.conf
105
 
                        RETVAL=$?
106
 
                        ;;
107
 
                suse)
108
 
                        echo -n "Starting $prog: "
109
 
                        startproc /usr/sbin/openhpid -c /etc/openhpi/openhpi.conf
110
 
                        RETVAL=$?
111
 
                        ;;
112
 
                lsb)
113
 
                        echo -n "Starting $prog: "
114
 
                        start_daemon /usr/sbin/openhpid -c /etc/openhpi/openhpi.conf
115
 
                        RETVAL=$?
116
 
                        ;;
117
 
                gentoo)
118
 
                        ebegin "Starting $prog: "
119
 
                        start-stop-daemon --start --quiet --exec /usr/sbin/openhpid -- -c /etc/openhpi/openhpi.conf
120
 
                        RETVAL=$?
121
 
                        ;;
122
 
                nolsb)
123
 
                        echo -n "Starting $prog: "
124
 
                        /usr/sbin/openhpid -c /etc/openhpi/openhpi.conf
125
 
                        RETVAL=$?
126
 
                        ;;
127
 
                        
128
 
        esac
129
 
        
130
 
        print_outcome
131
 
 
132
 
}
133
 
 
134
 
stop() {        
135
 
        case "${lsbtype}" in
136
 
                
137
 
                rh | lsb | suse)
138
 
                        echo -n "Stopping $prog: "
139
 
                        killproc /usr/sbin/openhpid
140
 
                        RETVAL=$?
141
 
                        ;;
142
 
                
143
 
                gentoo)
144
 
                        ebegin "Stopping $prog: "
145
 
                        start-stop-daemon --stop --quiet --exec /usr/sbin/openhpid
146
 
                        RETVAL=$?
147
 
                        ;;
148
 
                
149
 
                nolsb)
150
 
                        echo -n "Stopping $prog: "
151
 
                        if test -f /var/run/openhpid.pid && test "`cat /var/run/openhpid.pid`" != ""
152
 
                        then
153
 
                                kill "`cat /var/run/openhpid.pid`"
154
 
                                RETVAL=$?  
155
 
                        else
156
 
                                RETVAL=0
157
 
                        fi                
158
 
                        ;;
159
 
                
160
 
        esac
161
 
        
162
 
        print_outcome
163
 
        
164
 
        if test "$RETVAL" -eq 0 && test -f /var/run/openhpid.pid
165
 
        then
166
 
                rm -f /var/lock/openhpid
167
 
                rm -f /var/run/openhpid.pid
168
 
        fi      
169
 
 
170
 
}       
171
 
 
172
 
dstatus() {
173
 
        echo "Checking for $prog daemon: "
174
 
        
175
 
        case "${lsbtype}" in
176
 
                
177
 
                rh) 
178
 
                        status /usr/sbin/openhpid
179
 
                        ;;
180
 
                suse)
181
 
                        checkproc /usr/sbin/openhpid
182
 
                        rc_status -v
183
 
                        ;;
184
 
                lsb)
185
 
                        pid="`pidofproc /usr/sbin/openhpid`"
186
 
                        if test "${pid}" != ""
187
 
                        then
188
 
                                log_success_msg "$prog is running"
189
 
                        else
190
 
                                log_success_msg "$prog is not running"  
191
 
                        fi      
192
 
                        ;;
193
 
                gentoo | nolsb)
194
 
                        if test -f /var/run/openhpid.pid && 
195
 
                                test "`cat /var/run/openhpid.pid`" != "" && 
196
 
                                kill -s 0 "`cat /var/run/openhpid.pid`"
197
 
                        then
198
 
                                echo "$prog is running"
199
 
                        else
200
 
                                echo "$prog is not running"
201
 
                        fi              
202
 
                        
203
 
                        ;;
204
 
                        
205
 
        esac    
206
 
        
207
 
 
208
 
 
209
 
}       
210
 
 
211
 
restart() {
212
 
        stop
213
 
        start
214
 
}       
215
 
 
216
 
force_reload() {
217
 
        # We don't currently support a reload, but can do a restart
218
 
        stop
219
 
        start
220
 
}       
221
 
 
222
 
# See how we were called.
223
 
 
224
 
case "$1" in
225
 
  start)
226
 
        start
227
 
        ;;
228
 
  stop)
229
 
        stop
230
 
        ;;
231
 
  restart)
232
 
        restart
233
 
        ;;
234
 
  status)
235
 
        dstatus
236
 
        ;;
237
 
  force-reload)
238
 
        force_reload
239
 
        ;;
240
 
  *)
241
 
        echo "Usage: $0 {start|stop|restart|status|force-reload}"
242
 
        exit 1
243
 
esac