summaryrefslogtreecommitdiff
path: root/system/openais/rc.openais.new
blob: 8d9498afb750d523e71c75758fea04f68d162814 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/bin/sh
#
# corosync       Start the OpenAIS
#
# Author:       Andrew Beekhof <abeekhof@suse.de>
# License:      Revised BSD
#
# chkconfig: - 20 20
# processname:  corosync
# description:  OpenAIS
#
### BEGIN INIT INFO
# Description: corosync....
#
# Short-Description: OpenAIS
# Provides: corosync
# Required-Start: $network
# Should-Start: $syslog
# Required-Stop: $network
# Default-Start: 3 5
# Default-Stop: 0 6
### END INIT INFO

do_force=0
prog="corosync"
lockfile="/var/lock/subsys/$prog"

internal_status() {
    killall -0 corosync > /dev/null 2>&1
    return $?
}

status() {
    if
	! internal_status
    then
	echo "Stopped"
	return 7
    fi

    echo "Running"
    return 0
}

start() {
    echo -n $"Starting OpenAIS ($prog): "
    if
	! internal_status
    then
	echo -n "starting... "
	$prog 2>&1 > /dev/null 2>&1
	echo -n "rc=$?: "
    fi

    sleep 2 # give it time to fail... $? isn't definitive

    if
	internal_status
    then
	echo "OK"
	return 0
    fi

    echo "Failed"
    return 1
}

do_force=0
do_forever=1

stop() {
    echo -n $"Stopping OpenAIS ($prog): "

    killall -QUIT corosync

    if [ $do_forever = 0 ]; then
	for i in 1 2 3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20; do
	    if
		internal_status
	    then
		sleep 2
		echo -n "."
	    else
		rm -f "$lockfile"
		echo "OK"
		return 0
	    fi
	done

	if [ $do_force = 1 ]; then
	    echo -n "Escalating... "
	    killall -KILL corosync
	    sleep 5

	    if
		! internal_status
	    then
		rm -f "$lockfile"
		echo "OK"
		return 0
	    fi
	fi

	echo "Failed"
	return 1
    fi

    while
        internal_status
    do
	sleep 1
	echo -n "."
    done

    rm -f "$lockfile"
    echo "OK"
    return 0
}

restart() {
    stop
    start
}

case "$1" in
    start|stop|restart)
        $1
        ;;
    force-stop)
	do_force=1
        stop
        ;;
    reload|force-reload)
        restart
        ;;
    condrestart|try-restart)
        [ ! -f "$lockfile" ] || restart
        ;;
    status)
        status $prog
        ;;
    *)
        echo $"Usage: $0 {start|stop|restart|try-restart|condrestart|reload|force-reload|force-stop|status}"
        exit 2
esac