diff options
| author | Martin Schwenke <martin@meltin.net> | 2009-11-19 16:48:19 +1100 |
|---|---|---|
| committer | Martin Schwenke <martin@meltin.net> | 2009-11-19 16:48:19 +1100 |
| commit | a4a048b5cdb730dde5ebe0c153e90ec17569c0cc (patch) | |
| tree | 33a70235c6cc37b8299202d64e7ea13a17072c58 | |
| parent | ee513c1ba2292b86f1d3566a277570467e9d85c2 (diff) | |
Now vaguely tested initscript updates.
Signed-off-by: Martin Schwenke <martin@meltin.net>
(This used to be ctdb commit f1e350f9edb74cc44b6c5be4c062fd93e98ba8c4)
| -rwxr-xr-x | ctdb/config/ctdb.init | 2 | ||||
| -rwxr-xr-x | ctdb/config/events.d/01.reclock | 10 | ||||
| -rw-r--r-- | ctdb/config/events.d/20.multipathd | 3 | ||||
| -rwxr-xr-x | ctdb/config/events.d/40.vsftpd | 4 | ||||
| -rwxr-xr-x | ctdb/config/events.d/41.httpd | 2 | ||||
| -rwxr-xr-x | ctdb/config/events.d/50.samba | 141 | ||||
| -rwxr-xr-x | ctdb/config/events.d/70.iscsi | 4 | ||||
| -rwxr-xr-x | ctdb/config/events.d/99.timeout | 2 | ||||
| -rw-r--r-- | ctdb/config/functions | 20 |
9 files changed, 91 insertions, 97 deletions
diff --git a/ctdb/config/ctdb.init b/ctdb/config/ctdb.init index 67747fd149..4bd570d343 100755 --- a/ctdb/config/ctdb.init +++ b/ctdb/config/ctdb.init @@ -250,7 +250,7 @@ status() { } -case "$1" in +case "$cmd" in start) start ;; diff --git a/ctdb/config/events.d/01.reclock b/ctdb/config/events.d/01.reclock index 3d335507dd..1b6cbf09e4 100755 --- a/ctdb/config/events.d/01.reclock +++ b/ctdb/config/events.d/01.reclock @@ -10,15 +10,16 @@ case $cmd in ;; monitor) + RECLOCKFILE=$(ctdb -Y getreclock) + ctdb_counter_incr - (ctdb_counter_limit 200 >/dev/null 2>&1) || { - echo "Reclock file \"$RECLOCKFILE\" can not be accessed. Shutting down." + (ctdb_check_counter_limit 200 >/dev/null 2>&1) || { + echo "Reclock file $RECLOCKFILE\" can not be accessed. Shutting down." df sleep 1 ctdb shutdown } - RECLOCKFILE=$(ctdb -Y getreclock) [ -z "$RECLOCKFILE" ] && { # we are not using a reclock file ctdb_counter_init @@ -34,8 +35,7 @@ case $cmd in } ) >/dev/null 2>/dev/null & - - ctdb_counter_limit 3 + ctdb_check_counter_limit 3 quiet ;; status) ctdb_checkstatus || exit $? diff --git a/ctdb/config/events.d/20.multipathd b/ctdb/config/events.d/20.multipathd index 24f8f7aa98..cf722d8ce9 100644 --- a/ctdb/config/events.d/20.multipathd +++ b/ctdb/config/events.d/20.multipathd @@ -6,9 +6,10 @@ # CTDB_MONITOR_MPDEVICES="device1 device2 ..." # +. $CTDB_BASE/functions + service_name="multipathd" -. $CTDB_BASE/functions loadconfig [ -z "$CTDB_MONITOR_MPDEVICES" ] && { diff --git a/ctdb/config/events.d/40.vsftpd b/ctdb/config/events.d/40.vsftpd index d231690a23..582604aae3 100755 --- a/ctdb/config/events.d/40.vsftpd +++ b/ctdb/config/events.d/40.vsftpd @@ -1,6 +1,8 @@ #!/bin/sh # event strict to manage vsftpd in a cluster environment +. $CTDB_BASE/functions + service_name="vsftpd" # make sure the service is stopped first service_start="service $service_name stop > /dev/null 2>&1 ; service $service_name start" @@ -9,8 +11,6 @@ service_reconfigure="service $service_name restart" service_fail_limit=2 service_tcp_ports=21 -. $CTDB_BASE/functions - loadconfig ctdb_start_stop_service diff --git a/ctdb/config/events.d/41.httpd b/ctdb/config/events.d/41.httpd index 3e43f0f212..7f9ee23f24 100755 --- a/ctdb/config/events.d/41.httpd +++ b/ctdb/config/events.d/41.httpd @@ -28,7 +28,7 @@ cleanup_httpd_semaphore_leak() { ########## service_start="cleanup_httpd_semaphore_leak; service $service_name start" -service_stop="service $service_name stop; killall -q -9 $service_name" +service_stop="service $service_name stop; killall -q -9 $service_name || true" service_reconfigure="service $service_name restart" loadconfig diff --git a/ctdb/config/events.d/50.samba b/ctdb/config/events.d/50.samba index bd4c5ff006..e285347f60 100755 --- a/ctdb/config/events.d/50.samba +++ b/ctdb/config/events.d/50.samba @@ -1,13 +1,7 @@ #!/bin/sh # ctdb event script for Samba -PATH=/bin:/usr/bin:$PATH - -service_name="samba" - . $CTDB_BASE/functions -loadconfig ctdb -loadconfig samba detect_init_style @@ -22,11 +16,6 @@ case $CTDB_INIT_STYLE in CTDB_SERVICE_NMB=${CTDB_SERVICE_NMB:-""} CTDB_SERVICE_WINBIND=${CTDB_SERVICE_WINBIND:-winbind} ;; - redhat) - CTDB_SERVICE_SMB=${CTDB_SERVICE_SMB:-smb} - CTDB_SERVICE_NMB=${CTDB_SERVICE_NMB:-""} - CTDB_SERVICE_WINBIND=${CTDB_SERVICE_WINBIND:-winbind} - ;; *) # should not happen, but for now use redhat style as default: CTDB_SERVICE_SMB=${CTDB_SERVICE_SMB:-smb} @@ -35,11 +24,69 @@ case $CTDB_INIT_STYLE in ;; esac -cmd="$1" -shift +service_name="samba" +service_start="start_samba" +service_stop="stop_samba" + +loadconfig [ "$CTDB_MANAGES_SAMBA" = "yes" ] || [ "$CTDB_MANAGES_WINBIND" = "yes" ] || exit 0 +start_samba() { + # create the state directory for samba + /bin/mkdir -p $CTDB_BASE/state/samba + + # make sure samba is not already started + [ "$CTDB_MANAGES_SAMBA" = "yes" ] && { + service "$CTDB_SERVICE_SMB" stop > /dev/null 2>&1 + service "$CTDB_SERVICE_NMB" stop > /dev/null 2>&1 + killall -0 -q smbd && { + sleep 1 + # make absolutely sure samba is dead + killall -q -9 smbd + } + + killall -0 -q nmbd && { + sleep 1 + # make absolutely sure samba is dead + killall -q -9 nmbd + } + } + + # restart the winbind service + check_ctdb_manages_winbind + [ "$CTDB_MANAGES_WINBIND" = "yes" ] && { + service "$CTDB_SERVICE_WINBIND" stop > /dev/null 2>&1 + killall -0 -q winbindd && { + sleep 1 + # make absolutely sure winbindd is dead + killall -q -9 winbindd + } + service "$CTDB_SERVICE_WINBIND" start + } + + # start Samba service. Start it reniced, as under very heavy load + # the number of smbd processes will mean that it leaves few cycles for + # anything else + [ "$CTDB_MANAGES_SAMBA" = "yes" ] && { + nice_service "$CTDB_SERVICE_NMB" start + nice_service "$CTDB_SERVICE_SMB" start + } +} + +stop_samba() { + # shutdown Samba when ctdb goes down + [ "$CTDB_MANAGES_SAMBA" = "yes" ] && { + service "$CTDB_SERVICE_SMB" stop + service "$CTDB_SERVICE_NMB" stop + } + + # stop the winbind service + check_ctdb_manages_winbind + [ "$CTDB_MANAGES_WINBIND" = "yes" ] && { + service "$CTDB_SERVICE_WINBIND" stop + } +} # set default samba cleanup period - in minutes [ -z "$SAMBA_CLEANUP_PERIOD" ] && { @@ -143,72 +190,11 @@ periodic_cleanup() { case $cmd in startup) - # create the state directory for samba - /bin/mkdir -p $CTDB_BASE/state/samba - - # make sure samba is not already started - [ "$CTDB_MANAGES_SAMBA" = "yes" ] && { - service "$CTDB_SERVICE_SMB" stop > /dev/null 2>&1 - service "$CTDB_SERVICE_NMB" stop > /dev/null 2>&1 - killall -0 -q smbd && { - sleep 1 - # make absolutely sure samba is dead - killall -q -9 smbd - } - - killall -0 -q nmbd && { - sleep 1 - # make absolutely sure samba is dead - killall -q -9 nmbd - } - } - - # restart the winbind service - check_ctdb_manages_winbind - [ "$CTDB_MANAGES_WINBIND" = "yes" ] && { - service "$CTDB_SERVICE_WINBIND" stop > /dev/null 2>&1 - killall -0 -q winbindd && { - sleep 1 - # make absolutely sure winbindd is dead - killall -q -9 winbindd - } - service "$CTDB_SERVICE_WINBIND" start - } - - # start Samba service. Start it reniced, as under very heavy load - # the number of smbd processes will mean that it leaves few cycles for - # anything else - [ "$CTDB_MANAGES_SAMBA" = "yes" ] && { - nice_service "$CTDB_SERVICE_NMB" start - nice_service "$CTDB_SERVICE_SMB" start - } + ctdb_service_start ;; - takeip) - # nothing special for Samba - ;; - - releaseip) - # nothing special for Samba - ;; - - recovered) - # nothing special for Samba - exit 0 - ;; - shutdown) - # shutdown Samba when ctdb goes down - [ "$CTDB_MANAGES_SAMBA" = "yes" ] && { - service "$CTDB_SERVICE_SMB" stop - service "$CTDB_SERVICE_NMB" stop - } - - # stop the winbind service - check_ctdb_manages_winbind - [ "$CTDB_MANAGES_WINBIND" = "yes" ] && { - service "$CTDB_SERVICE_WINBIND" stop - } + ctdb_service_stop ;; monitor) @@ -257,6 +243,9 @@ case $cmd in } ;; + status) + ctdb_checkstatus || exit $? + ;; esac # ignore unknown commands diff --git a/ctdb/config/events.d/70.iscsi b/ctdb/config/events.d/70.iscsi index 2ab34aca3f..8cbf457eb4 100755 --- a/ctdb/config/events.d/70.iscsi +++ b/ctdb/config/events.d/70.iscsi @@ -1,10 +1,10 @@ #!/bin/sh # ctdb event script for TGTD based iSCSI -service_name="iscsi" - . $CTDB_BASE/functions +service_name="iscsi" + ctdb_start_stop_service [ -z "$CTDB_START_ISCSI_SCRIPTS" ] && { diff --git a/ctdb/config/events.d/99.timeout b/ctdb/config/events.d/99.timeout index 6a5aed05a3..a1201bfc5c 100755 --- a/ctdb/config/events.d/99.timeout +++ b/ctdb/config/events.d/99.timeout @@ -7,7 +7,7 @@ . $CTDB_BASE/functions loadconfig ctdb -[ "x$CTDB_RUN_TIMEOUT_MONITOR" = "xyes" ] || exit 0 +[ "$CTDB_RUN_TIMEOUT_MONITOR" = "yes" ] || exit 0 case $cmd in monitor) diff --git a/ctdb/config/functions b/ctdb/config/functions index d68f607376..2d60cb4309 100644 --- a/ctdb/config/functions +++ b/ctdb/config/functions @@ -509,7 +509,7 @@ _ctdb_counter_common () { ctdb_counter_init () { _ctdb_counter_common - echo -n > "$_counter_file" + >"$_counter_file" } ctdb_counter_incr () { _ctdb_counter_common @@ -520,13 +520,16 @@ ctdb_counter_incr () { ctdb_check_counter_limit () { _ctdb_counter_common + _limit="${1:-${service_fail_limit}}" + _quiet="$2" + # unary counting! _size=$(stat -c "%s" "$_counter_file" 2>/dev/null || echo 0) - if [ $_size -ge $service_fail_limit ] ; then - echo "ERROR: more than $service_fail_limit consecutive failures, marking cluster unhealthy" + if [ $_size -ge $_limit ] ; then + echo "ERROR: more than $_limit consecutive failures for $service_name, marking cluster unhealthy" exit 1 - else - echo "WARNING: less than $service_fail_limit consecutive failures, not unhealthy yet" + elif [ $_size -gt 0 -a -z "$_quiet" ] ; then + echo "WARNING: less than $_limit consecutive failures ($_size) for $service_name, not unhealthy yet" fi } ######################################################## @@ -585,7 +588,7 @@ ctdb_service_unset_reconfigure () ctdb_service_reconfigure () { if [ -n "$service_reconfigure" ] ; then - $service_reconfigure + eval $service_reconfigure else service "$service_name" restart fi @@ -641,7 +644,7 @@ ctdb_start_stop_service () ctdb_service_start () { if [ -n "$service_start" ] ; then - $service_start + eval $service_start else service "$service_name" start fi @@ -651,7 +654,7 @@ ctdb_service_start () ctdb_service_stop () { if [ -n "$service_stop" ] ; then - $service_stop + eval $service_stop else service "$service_name" stop fi @@ -673,6 +676,7 @@ ctdb_service_stop () # A reasonable default is the basename of the eventscript. service_name="${0##*/}" # basename +service_fail_limit=1 ctdb_event="$1" ; shift cmd="$ctdb_event" |
