~upstart-devel/upstart/upstart-jobs

« back to all changes in this revision

Viewing changes to sid/etc/init.d/ibacm

  • Committer: Dimitri John Ledkov
  • Date: 2014-11-19 14:08:18 UTC
  • Revision ID: dimitri.j.ledkov@intel.com-20141119140818-xlb2v9ahs1h2e5tq
update

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash
 
2
#
 
3
# Bring up/down the ibacm daemon
 
4
#
 
5
# chkconfig: 2345 25 75
 
6
# description: Starts/Stops InfiniBand ACM service
 
7
#
 
8
### BEGIN INIT INFO
 
9
# Provides:       ibacm
 
10
# Default-Start: 2 3 4 5
 
11
# Default-Stop: 0 1 6
 
12
# Required-Start: $network $remote_fs
 
13
# Required-Stop: $network $remote_fs
 
14
# Should-Start:
 
15
# Should-Stop:
 
16
# Short-Description: Starts and stops the InfiniBand ACM service
 
17
# Description: The InfiniBand ACM service provides a user space implementation
 
18
#       of something resembling an ARP cache for InfiniBand SA queries and
 
19
#       host route lookups.
 
20
### END INIT INFO
 
21
 
 
22
pidfile=/var/run/ibacm.pid
 
23
subsys=/var/lock/subsys/ibacm
 
24
 
 
25
daemon() { /sbin/daemon   ${1+"$@"}; }
 
26
 
 
27
if [ -s /etc/init.d/functions ]; then
 
28
        # RHEL / CentOS / SL / Fedora
 
29
        . /etc/init.d/functions
 
30
        _daemon()   { daemon ${1+"$@"}; }
 
31
        _checkpid() { checkpid `cat $pidfile`; }
 
32
        _success()  { success; echo; }
 
33
        _failure()  { failure; echo; }
 
34
elif [ -s /lib/lsb/init-functions ]; then
 
35
        # SLES / OpenSuSE / Debian
 
36
        . /lib/lsb/init-functions
 
37
        _daemon()   { /sbin/start_daemon ${1+"$@"}; }
 
38
        _checkpid() { checkproc -p $pidfile /usr/sbin/ibacm; }
 
39
        _success()  { log_success_msg; }
 
40
        _failure()  { log_failure_msg; }
 
41
elif [ -s /etc/rc.status ]; then
 
42
        # Older SuSE
 
43
        . /etc/rc.status
 
44
        _daemon()   { /sbin/start_daemon ${1+"$@"}; }
 
45
        _checkpid() { checkproc -p $pidfile /usr/sbin/ibacm; }
 
46
        _success()  { rc_status -v; }
 
47
        _failure()  { rc_status -v; }
 
48
fi      
 
49
 
 
50
start()
 
51
{
 
52
    echo -n "Starting ibacm daemon:"
 
53
    _daemon /usr/sbin/ibacm
 
54
    if [[ $RETVAL -eq 0 ]]; then
 
55
        _success
 
56
    else
 
57
        _failure
 
58
    fi
 
59
}
 
60
 
 
61
stop()
 
62
{
 
63
    echo -n "Stopping ibacm daemon:"
 
64
    killproc -p $pidfile ibacm
 
65
    if [[ $RETVAL -eq 0 ]]; then
 
66
        _success
 
67
    else
 
68
        _failure
 
69
    fi
 
70
    rm -f $subsys
 
71
}
 
72
 
 
73
status()
 
74
{
 
75
    echo -n "Checking for ibacm service "
 
76
    if [ ! -f $subsys -a ! -f $pidfile ]; then
 
77
        RETVAL=3
 
78
    elif [ -f $pidfile ]; then
 
79
        _checkpid
 
80
        RETVAL=$?
 
81
    elif [ -f $subsys ]; then
 
82
        RETVAL=2
 
83
    else
 
84
        RETVAL=0
 
85
    fi
 
86
    if [[ $RETVAL -eq 0 ]]; then
 
87
        _success
 
88
    else
 
89
        _failure
 
90
    fi
 
91
}
 
92
 
 
93
restart ()
 
94
{
 
95
    stop
 
96
    start
 
97
}
 
98
 
 
99
condrestart ()
 
100
{
 
101
    [ -e $subsys ] && restart || return 0
 
102
}
 
103
 
 
104
usage ()
 
105
{
 
106
    echo
 
107
    echo "Usage: `basename $0` {start|stop|restart|condrestart|try-restart|force-reload|status}"
 
108
    echo
 
109
    return 2
 
110
}
 
111
 
 
112
case $1 in
 
113
    start|stop|restart|condrestart|try-restart|force-reload)
 
114
        [ `id -u` != "0" ] && exit 4 ;;
 
115
esac
 
116
 
 
117
case $1 in
 
118
    start)
 
119
        start
 
120
        ;;
 
121
    stop)
 
122
        stop
 
123
        ;;
 
124
    restart | reload)
 
125
        restart
 
126
        ;;
 
127
    condrestart | try-restart | force-reload)
 
128
        condrestart
 
129
        ;;
 
130
    status)
 
131
        status
 
132
        ;;
 
133
    *)
 
134
        usage
 
135
        ;;
 
136
esac
 
137
 
 
138
exit $RETVAL