~ubuntu-branches/ubuntu/oneiric/likewise-open/oneiric

« back to all changes in this revision

Viewing changes to config/init-lwsm.sh

  • Committer: Bazaar Package Importer
  • Author(s): Scott Salley
  • Date: 2010-11-22 12:06:00 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20101122120600-8lba1fpceot71wlb
Tags: 6.0.0.53010-1
Likewise Open 6.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/sh
2
 
# Implicit arguments
3
 
#  PREFIX - prefix of Likewise installation
4
 
#  SERVICE_NAME - name of the service
5
 
 
6
 
LWSM="${PREFIX}/bin/lwsm"
7
 
 
8
 
PLATFORM=""
9
 
if [ -f /etc/init.d/functions ]; then
10
 
    . /etc/init.d/functions
11
 
    PLATFORM="REDHAT"
12
 
elif [ -f /etc/rc.status ]; then
13
 
    . /etc/rc.status
14
 
    PLATFORM="SUSE"
15
 
elif [ -f /etc/debian_version ]; then
16
 
    . /lib/lsb/init-functions
17
 
    PLATFORM="DEBIAN"
18
 
elif [ "`uname -s`" = 'AIX' ]; then
19
 
    PLATFORM="AIX"
20
 
elif [ "`uname -s`" = 'HP-UX' ]; then
21
 
    PLATFORM="HP-UX"
22
 
elif [ "`uname -s`" = 'SunOS' ]; then
23
 
    PLATFORM="SOLARIS"
24
 
elif [ "`uname -s`" = 'VMkernel' ]; then                                  
25
 
    PLATFORM="ESXI"                             
26
 
elif [ "`uname`" = "FreeBSD" ]; then
27
 
    PLATFORM="FREEBSD"
28
 
else
29
 
    PLATFORM="UNKNOWN"
30
 
fi
31
 
 
32
 
service_description()
33
 
{
34
 
    ${LWSM} info "$1" | grep '^Description:' | sed 's/^Description: //'
35
 
}
36
 
 
37
 
service_progname()
38
 
{
39
 
    basename "`${LWSM} info "$1" | grep '^Path:' | sed 's/^Path: //'`"
40
 
}
41
 
 
42
 
service_start()
43
 
{
44
 
    status=""
45
 
 
46
 
    case "${PLATFORM}" in
47
 
        REDHAT)
48
 
            printf "%s" "Starting `service_progname $1`: " 
49
 
            daemon ${LWSM} -q start "${1}"
50
 
            status=$?
51
 
            if [ $status -eq 0 ]
52
 
            then
53
 
                echo_success
54
 
                echo
55
 
            else
56
 
                echo_failure
57
 
                echo
58
 
            fi
59
 
            ;;
60
 
        SUSE)
61
 
            printf "%s" "Starting `service_description $1`"
62
 
            ${LWSM} -q start "${1}"
63
 
            status=$?
64
 
            if [ $status -eq 0 ]
65
 
            then
66
 
                rc_reset
67
 
                rc_status -v
68
 
            else
69
 
                rc_failed $status
70
 
                rc_status -v
71
 
            fi
72
 
            ;;
73
 
        DEBIAN)
74
 
            log_daemon_msg "Starting `service_description $1`: `service_progname $1`"
75
 
            start-stop-daemon --start --exec ${LWSM} -- -q start "${1}"
76
 
            status=$?
77
 
            log_end_msg $status
78
 
            ;;
79
 
        AIX)
80
 
            printf "%s" "Starting `service_description $1`"
81
 
            if (lssrc -s dhcpcd | grep active >/dev/null); then
82
 
                # Wait up to 30 seconds for an ip address
83
 
                for i in `seq 30`; do
84
 
                    ifconfig -a | grep inet | grep -v 127.0.0 | grep -v 0.0.0.0 | grep -v ::1/0 >/dev/null && break
85
 
                    sleep 1
86
 
                done
87
 
            fi
88
 
            ${LWSM} -q start "${1}"
89
 
            status=$?
90
 
            ;;
91
 
         HP-UX | SOLARIS | FREEBSD | ESXI)
92
 
            printf "%s" "Starting `service_description $1`"
93
 
            ${LWSM} -q start "${1}"
94
 
            status=$?
95
 
            if [ $status -eq 0 ]
96
 
            then
97
 
                echo " ...ok"
98
 
            else
99
 
                echo " ...failed"
100
 
            fi
101
 
            ;;
102
 
        UNKNOWN)
103
 
            ${LWSM} -q start "${1}"
104
 
            status=$?
105
 
            ;;
106
 
    esac
107
 
 
108
 
    return $status
109
 
}
110
 
 
111
 
service_restart()
112
 
{
113
 
    status=""
114
 
 
115
 
    case "${PLATFORM}" in
116
 
        REDHAT)
117
 
            printf "%s" "Restarting `service_progname $1`: " 
118
 
            daemon ${LWSM} -q restart "${1}"
119
 
            status=$?
120
 
            if [ $status -eq 0 ]
121
 
            then
122
 
                echo_success
123
 
                echo
124
 
            else
125
 
                echo_failure
126
 
                echo
127
 
            fi
128
 
            ;;
129
 
        SUSE)
130
 
            printf "%s" "Restarting `service_description $1`"
131
 
            ${LWSM} -q restart "${1}"
132
 
            status=$?
133
 
            if [ $status -eq 0 ]
134
 
            then
135
 
                rc_reset
136
 
                rc_status -v
137
 
            else
138
 
                rc_failed $status
139
 
                rc_status -v
140
 
            fi
141
 
            ;;
142
 
        DEBIAN)
143
 
            log_daemon_msg "Restarting `service_description $1`: `service_progname $1`"
144
 
            start-stop-daemon --start --exec ${LWSM} -- -q restart "${1}"
145
 
            status=$?
146
 
            log_end_msg $status
147
 
            ;;
148
 
        AIX)
149
 
            printf "%s" "Restarting `service_description $1`"
150
 
            if (lssrc -s dhcpcd | grep active >/dev/null); then
151
 
                # Wait up to 30 seconds for an ip address
152
 
                for i in `seq 30`; do
153
 
                    ifconfig -a | grep inet | grep -v 127.0.0 | grep -v 0.0.0.0 | grep -v ::1/0 >/dev/null && break
154
 
                    sleep 1
155
 
                done
156
 
            fi
157
 
            ${LWSM} -q restart "${1}"
158
 
            status=$?
159
 
            ;;
160
 
         HP-UX | SOLARIS | FREEBSD | ESXI)
161
 
            printf "%s" "Restarting `service_description $1`"
162
 
            ${LWSM} -q restart "${1}"
163
 
            status=$?
164
 
            if [ $status -eq 0 ]
165
 
            then
166
 
                echo " ...ok"
167
 
            else
168
 
                echo " ...failed"
169
 
            fi
170
 
            ;;
171
 
        UNKNOWN)
172
 
            ${LWSM} -q restart "${1}"
173
 
            status=$?
174
 
            ;;
175
 
    esac
176
 
 
177
 
    return $status
178
 
}
179
 
 
180
 
service_stop()
181
 
{
182
 
    status=""
183
 
 
184
 
    case "${PLATFORM}" in 
185
 
        REDHAT)
186
 
            printf "%s" $"Stopping `service_progname $1`: "
187
 
            ${LWSM} -q stop "${1}"
188
 
            status=$?
189
 
            if [ $status -eq 0 ]
190
 
            then
191
 
                echo_success
192
 
                echo
193
 
            else
194
 
                echo_failure
195
 
                echo
196
 
            fi
197
 
            ;;
198
 
        SUSE)
199
 
            printf "%s" "Stopping `service_description $1`"
200
 
            ${LWSM} -q stop "${1}"
201
 
            status=$?
202
 
            if [ $status -eq 0 ]
203
 
            then
204
 
                rc_reset
205
 
                rc_status -v
206
 
            else
207
 
                rc_failed $status
208
 
                rc_status -v
209
 
            fi
210
 
            ;;
211
 
        DEBIAN)
212
 
            log_daemon_msg "Stopping `service_description $1`: `service_progname $1`"
213
 
            ${LWSM} -q stop "${1}"
214
 
            status=$?
215
 
            log_end_msg $status
216
 
            ;;
217
 
        AIX | HP-UX | SOLARIS | FREEBSD | ESXI)
218
 
            printf "%s" "Stopping `service_description $1`"
219
 
            ${LWSM} -q stop "${1}"
220
 
            status=$?
221
 
            if [ $status -eq 0 ]
222
 
            then
223
 
                echo " ...ok"
224
 
            else
225
 
                echo " ...failed"
226
 
            fi
227
 
            ;;
228
 
        UNKNOWN)
229
 
            ${LWSM} -q stop "${1}"
230
 
            status=$?
231
 
            ;;
232
 
    esac
233
 
 
234
 
    return $status
235
 
}
236
 
 
237
 
service_refresh()
238
 
{
239
 
    case "${PLATFORM}" in 
240
 
        REDHAT)
241
 
            printf "%s" $"Refreshing `service_description $1` configuration"
242
 
            ${LWSM} -q refresh "$1"
243
 
            status=$?
244
 
            if [ $status -eq 0 ]
245
 
            then
246
 
                echo_success
247
 
                echo
248
 
            else
249
 
                echo_failure
250
 
                echo
251
 
            fi
252
 
            ;;
253
 
        SUSE)
254
 
            printf "%s" $"Refreshing `service_description $1` configuration"
255
 
            ${LWSM} -q refresh "$1"
256
 
            status=$?
257
 
            if [ $status -eq 0 ]
258
 
            then
259
 
                rc_reset
260
 
                rc_status -v
261
 
            else
262
 
                rc_failed $status
263
 
                rc_status -v
264
 
            fi
265
 
            ;;
266
 
        DEBIAN)
267
 
            log_daemon_msg "Refreshing `service_description $1` configuration"
268
 
            ${LWSM} -q refresh "$1"
269
 
            status=$?
270
 
            log_end_msg $status
271
 
            ;;
272
 
        AIX | HP-UX | SOLARIS | FREEBSD | ESXI)
273
 
            printf "%s" "Refreshing `service_description $1` configuration"
274
 
            ${LWSM} -q refresh "$1"
275
 
            status=$?
276
 
            if [ $status -eq 0 ]
277
 
            then
278
 
                echo " ...ok"
279
 
            else
280
 
                echo " ...failed"
281
 
            fi
282
 
            ;;
283
 
        UNKNOWN)
284
 
            ${LWSM} -q refresh "$1"
285
 
            status=$?
286
 
            ;;
287
 
    esac
288
 
 
289
 
    return $status
290
 
}
291
 
 
292
 
case "$1" in
293
 
    start)
294
 
        service_start "$SERVICE_NAME"
295
 
        exit $?
296
 
        ;;
297
 
    stop)
298
 
        service_stop "$SERVICE_NAME"
299
 
        exit $?
300
 
        ;;
301
 
    status)
302
 
        $LWSM status "$SERVICE_NAME"
303
 
        case "$?" in
304
 
            0)
305
 
                exit 0
306
 
                ;;
307
 
            1)
308
 
                exit 3
309
 
                ;;
310
 
            2)
311
 
                exit 3
312
 
                ;;
313
 
            3)
314
 
                exit 3
315
 
                ;;
316
 
            4)
317
 
                exit 0
318
 
                ;;
319
 
            5)
320
 
                exit 2
321
 
                ;;
322
 
            *)
323
 
                exit 1
324
 
                ;;
325
 
        esac
326
 
        ;;
327
 
    info)
328
 
        $LWSM info "$SERVICE_NAME"
329
 
        exit $?
330
 
        ;;
331
 
    restart)
332
 
        service_restart "$SERVICE_NAME"
333
 
        exit $?
334
 
        ;;
335
 
    refresh|reload)
336
 
        service_refresh "$SERVICE_NAME"
337
 
        exit $?
338
 
        ;;
339
 
    start_msg)
340
 
        echo "Starting `service_description $SERVICE_NAME`"
341
 
        exit 0
342
 
        ;;
343
 
    stop_msg)
344
 
        echo "Stopping `service_description $SERVICE_NAME`"
345
 
        exit 0
346
 
        ;;
347
 
    *)
348
 
        echo "Unrecognized command: $1"
349
 
        exit 1
350
 
        ;;
351
 
esac