You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gentoo-overlay/dev-db/ctdb/files/ctdb.initd

82 lines
3.0 KiB

#!/sbin/runscript
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
}