~ubuntu-branches/ubuntu/vivid/ctdb/vivid-proposed

« back to all changes in this revision

Viewing changes to config/ctdb.init

  • Committer: Bazaar Package Importer
  • Author(s): Mathieu Parent
  • Date: 2008-04-26 15:21:27 UTC
  • Revision ID: james.westby@ubuntu.com-20080426152127-58mv5ojv5q362ise
Tags: upstream-1.0.34+git200804242206
ImportĀ upstreamĀ versionĀ 1.0.34+git200804242206

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
#
 
3
##############################
 
4
# init info for redhat distros
 
5
# chkconfig: - 90 36
 
6
# description: Starts and stops the clustered tdb daemon
 
7
# pidfile: /var/run/ctdbd/ctdbd.pid
 
8
##############################
 
9
 
 
10
##############################
 
11
# SLES/OpenSuSE init info
 
12
### BEGIN INIT INFO
 
13
# Provides:       ctdb
 
14
# Required-Start: $network
 
15
# Required-Stop:
 
16
# Default-Start:  3 5
 
17
# Default-Stop:
 
18
# Description:    initscript for the ctdb service
 
19
### END INIT INFO
 
20
 
 
21
# Source function library.
 
22
if [ -f /etc/init.d/functions ] ; then
 
23
  . /etc/init.d/functions
 
24
elif [ -f /etc/rc.d/init.d/functions ] ; then
 
25
  . /etc/rc.d/init.d/functions
 
26
fi
 
27
 
 
28
[ -f /etc/rc.status ] && {
 
29
    . /etc/rc.status
 
30
    rc_reset
 
31
    LC_ALL=en_US.UTF-8
 
32
}
 
33
 
 
34
# Avoid using root's TMPDIR
 
35
unset TMPDIR
 
36
 
 
37
[ -z "$CTDB_BASE" ] && {
 
38
    export CTDB_BASE="/etc/ctdb"
 
39
}
 
40
 
 
41
. $CTDB_BASE/functions
 
42
loadconfig network
 
43
loadconfig ctdb
 
44
 
 
45
# check networking is up (for redhat)
 
46
[ "${NETWORKING}" = "no" ] && exit 0
 
47
 
 
48
[ -z "$CTDB_RECOVERY_LOCK" ] && {
 
49
    echo "You must configure the location of the CTDB_RECOVERY_LOCK"
 
50
    exit 1
 
51
}
 
52
CTDB_OPTIONS="$CTDB_OPTIONS --reclock=$CTDB_RECOVERY_LOCK"
 
53
 
 
54
# build up CTDB_OPTIONS variable from optional parameters
 
55
[ -z "$CTDB_LOGFILE" ]          || CTDB_OPTIONS="$CTDB_OPTIONS --logfile=$CTDB_LOGFILE"
 
56
[ -z "$CTDB_NODES" ]            || CTDB_OPTIONS="$CTDB_OPTIONS --nlist=$CTDB_NODES"
 
57
[ -z "$CTDB_SOCKET" ]           || CTDB_OPTIONS="$CTDB_OPTIONS --socket=$CTDB_SOCKET"
 
58
[ -z "$CTDB_PUBLIC_ADDRESSES" ] || CTDB_OPTIONS="$CTDB_OPTIONS --public-addresses=$CTDB_PUBLIC_ADDRESSES"
 
59
[ -z "$CTDB_PUBLIC_INTERFACE" ] || CTDB_OPTIONS="$CTDB_OPTIONS --public-interface=$CTDB_PUBLIC_INTERFACE"
 
60
[ -z "$CTDB_SINGLE_PUBLIC_IP" ] || CTDB_OPTIONS="$CTDB_OPTIONS --single-public-ip=$CTDB_SINGLE_PUBLIC_IP"
 
61
[ -z "$CTDB_DBDIR" ]            || CTDB_OPTIONS="$CTDB_OPTIONS --dbdir=$CTDB_DBDIR"
 
62
[ -z "$CTDB_DBDIR_PERSISTENT" ] || CTDB_OPTIONS="$CTDB_OPTIONS --dbdir-persistent=$CTDB_DBDIR_PERSISTENT"
 
63
[ -z "$CTDB_EVENT_SCRIPT_DIR" ] || CTDB_OPTIONS="$CTDB_OPTIONS --event-script-dir $CTDB_EVENT_SCRIPT_DIR"
 
64
[ -z "$CTDB_TRANSPORT" ]        || CTDB_OPTIONS="$CTDB_OPTIONS --transport $CTDB_TRANSPORT"
 
65
[ -z "$CTDB_DEBUGLEVEL" ]       || CTDB_OPTIONS="$CTDB_OPTIONS -d $CTDB_DEBUGLEVEL"
 
66
[ -z "$CTDB_START_AS_DISABLED" ] || [ "$CTDB_START_AS_DISABLED" != "yes" ] || {
 
67
        CTDB_OPTIONS="$CTDB_OPTIONS --start-as-disabled"
 
68
}
 
69
 
 
70
if [ -x /sbin/startproc ]; then
 
71
    init_style="suse"
 
72
else if [ -x /sbin/start-stop-daemon ]; then
 
73
        init_style="ubuntu"
 
74
    else
 
75
        init_style="redhat"
 
76
    fi
 
77
fi
 
78
 
 
79
start() {
 
80
        killall -q ctdbd
 
81
        echo -n $"Starting ctdbd service: "
 
82
        case $init_style in
 
83
            suse)
 
84
                startproc /usr/sbin/ctdbd $CTDB_OPTIONS
 
85
                rc_status -v
 
86
                RETVAL=$?
 
87
                ;;
 
88
            redhat)
 
89
                daemon ctdbd $CTDB_OPTIONS
 
90
                RETVAL=$?
 
91
                echo
 
92
                [ $RETVAL -eq 0 ] && touch /var/lock/subsys/ctdb || RETVAL=1
 
93
                ;;
 
94
            ubuntu)
 
95
                start-stop-daemon --start --quiet --background --exec /usr/sbin/ctdbd -- $CTDB_OPTIONS
 
96
                RETVAL=$?
 
97
                ;;
 
98
        esac
 
99
 
 
100
        sleep 1
 
101
        # set any tunables from the config file
 
102
        set | grep ^CTDB_SET_ | cut -d_ -f3- | 
 
103
        while read v; do
 
104
            varname=`echo $v | cut -d= -f1`
 
105
            value=`echo $v | cut -d= -f2`
 
106
            ctdb setvar $varname $value || RETVAL=1
 
107
        done || exit 1
 
108
 
 
109
        return $RETVAL
 
110
}       
 
111
 
 
112
stop() {
 
113
        echo -n $"Shutting down ctdbd service: "
 
114
        ctdb shutdown
 
115
        RETVAL=$?
 
116
        count=0
 
117
        while killall -q -0 ctdbd; do
 
118
            sleep 1
 
119
            count=`expr $count + 1`
 
120
            [ $count -gt 10 ] && {
 
121
                echo -n $"killing ctdbd "
 
122
                killall -q -9 ctdbd
 
123
                pkill -9 -f $CTDB_BASE/events.d/
 
124
            }
 
125
        done
 
126
        case $init_style in
 
127
            suse)
 
128
                rc_status -v
 
129
                ;;
 
130
            redhat)
 
131
                echo
 
132
                [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/ctdb
 
133
                echo ""
 
134
                return $RETVAL
 
135
                ;;
 
136
        esac
 
137
}       
 
138
 
 
139
restart() {
 
140
        stop
 
141
        start
 
142
}       
 
143
 
 
144
status() {
 
145
        ctdb status
 
146
}       
 
147
 
 
148
 
 
149
case "$1" in
 
150
  start)
 
151
        start
 
152
        ;;
 
153
  stop)
 
154
        stop
 
155
        ;;
 
156
  restart)
 
157
        restart
 
158
        ;;
 
159
  status)
 
160
        status
 
161
        ;;
 
162
  condrestart)
 
163
        ctdb status > /dev/null && restart || :
 
164
        ;;
 
165
  cron)
 
166
        # used from cron to auto-restart ctdb
 
167
        ctdb status > /dev/null || restart
 
168
        ;;
 
169
  *)
 
170
        echo $"Usage: $0 {start|stop|restart|status|cron|condrestart}"
 
171
        exit 1
 
172
esac
 
173
 
 
174
exit $?