forked from gentoo/gentoo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ctdb.initd
81 lines (69 loc) · 2.99 KB
/
ctdb.initd
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
#!/sbin/openrc-run
depend() {
need localmount
need net
before samba
after bootmisc
}
start() {
ebegin "Starting ctdb"
[ -z "$CTDB_RECOVERY_LOCK" ] && {
eerror "You must configure the location of the CTDB_RECOVERY_LOCK in /etc/conf.d/ctdb"
return 1
}
[ -z "$CTDB_PUBLIC_ADDRESSES" ] && {
eerror "You must configure the location of the CTDB_PUBLIC_ADDRESSES in /etc/conf.d/ctdb"
return 1
}
[ -z "$CTDB_PUBLIC_INTERFACE" ] && {
eerror "You must configure the location of the CTDB_PUBLIC_INTERFACE in /etc/conf.d/ctdb"
return 1
}
CTDB_OPTIONS="$CTDB_OPTIONS --reclock=$CTDB_RECOVERY_LOCK"
# build up CTDB_OPTIONS variable from optional parameters
[ -z "$CTDB_LOGFILE" ] || CTDB_OPTIONS="$CTDB_OPTIONS --logfile=$CTDB_LOGFILE"
[ -z "$CTDB_NODES" ] || CTDB_OPTIONS="$CTDB_OPTIONS --nlist=$CTDB_NODES"
[ -z "$CTDB_SOCKET" ] || CTDB_OPTIONS="$CTDB_OPTIONS --socket=$CTDB_SOCKET"
[ -z "$CTDB_PUBLIC_ADDRESSES" ] || CTDB_OPTIONS="$CTDB_OPTIONS --public-addresses=$CTDB_PUBLIC_ADDRESSES"
[ -z "$CTDB_PUBLIC_INTERFACE" ] || CTDB_OPTIONS="$CTDB_OPTIONS --public-interface=$CTDB_PUBLIC_INTERFACE"
[ -z "$CTDB_SINGLE_PUBLIC_IP" ] || CTDB_OPTIONS="$CTDB_OPTIONS --single-public-ip=$CTDB_SINGLE_PUBLIC_IP"
[ -z "$CTDB_DBDIR" ] || CTDB_OPTIONS="$CTDB_OPTIONS --dbdir=$CTDB_DBDIR"
[ -z "$CTDB_DBDIR_PERSISTENT" ] || CTDB_OPTIONS="$CTDB_OPTIONS --dbdir-persistent=$CTDB_DBDIR_PERSISTENT"
[ -z "$CTDB_EVENT_SCRIPT_DIR" ] || CTDB_OPTIONS="$CTDB_OPTIONS --event-script-dir $CTDB_EVENT_SCRIPT_DIR"
[ -z "$CTDB_TRANSPORT" ] || CTDB_OPTIONS="$CTDB_OPTIONS --transport $CTDB_TRANSPORT"
[ -z "$CTDB_DEBUGLEVEL" ] || CTDB_OPTIONS="$CTDB_OPTIONS -d $CTDB_DEBUGLEVEL"
[ -z "$CTDB_START_AS_DISABLED" ] || [ "$CTDB_START_AS_DISABLED" != "yes" ] || {
CTDB_OPTIONS="$CTDB_OPTIONS --start-as-disabled"
}
[ -z "$CTDB_CAPABILITY_RECMASTER" ] || [ "$CTDB_CAPABILITY_RECMASTER" != "no" ] || {
CTDB_OPTIONS="$CTDB_OPTIONS --no-recmaster"
}
[ -z "$CTDB_CAPABILITY_LMASTER" ] || [ "$CTDB_CAPABILITY_LMASTER" != "no" ] || {
CTDB_OPTIONS="$CTDB_OPTIONS --no-lmaster"
}
[ -z "$CTDB_LVS_PUBLIC_IP" ] || {
CTDB_OPTIONS="$CTDB_OPTIONS --lvs"
}
[ -z "$CTDB_SCRIPT_LOG_LEVEL" ] || {
CTDB_OPTIONS="$CTDB_OPTIONS --script-log-level=$CTDB_SCRIPT_LOG_LEVEL"
}
# check all persistent databases that they look ok
PERSISTENT_DB_DIR="/var/ctdb/persistent"
[ -z "$CTDB_DBDIR" ] || {
PERSISTENT_DB_DIR="$CTDB_DBDIR/persistent"
}
mkdir -p $PERSISTENT_DB_DIR 2>/dev/null
for PDBASE in `ls $PERSISTENT_DB_DIR/*.tdb.[0-9] 2>/dev/null`; do
/usr/bin/tdbdump $PDBASE >/dev/null 2>/dev/null || {
eerror "Persistent database $PDBASE is corrupted! CTDB will not start."
return 1
}
done
start-stop-daemon --start --background --exec /usr/sbin/ctdbd \
--pidfile /var/run/ctdbd.pid -- $CTDB_OPTIONS
eend $?
}
stop() {
start-stop-daemon --stop --exec /usr/sbin/ctdbd \
--pidfile /var/run/ctdbd.pid
}