diff options
author | Ronnie Sahlberg <ronniesahlberg@gmail.com> | 2011-08-10 15:22:46 +1000 |
---|---|---|
committer | Ronnie Sahlberg <ronniesahlberg@gmail.com> | 2011-08-10 15:22:46 +1000 |
commit | 184ac88e45ca9067e37b22b0fff43f4ff8db8d01 (patch) | |
tree | f5325b5a078bdc42686b7157cdc88c9d274944f0 | |
parent | 3c7fb84774f8538bab8b3b73913acb04a91f143b (diff) | |
parent | 061b7adad6a871de3a9380a4c308e733f57af90c (diff) | |
download | samba-184ac88e45ca9067e37b22b0fff43f4ff8db8d01.tar.gz samba-184ac88e45ca9067e37b22b0fff43f4ff8db8d01.tar.xz samba-184ac88e45ca9067e37b22b0fff43f4ff8db8d01.zip |
Merge remote branch 'martins/eventscript.13.per_ip_routing'
(This used to be ctdb commit 20984a28d9617c0b7a5868057594920ed3f1a2c7)
-rw-r--r-- | ctdb/config/README | 37 | ||||
-rwxr-xr-x | ctdb/config/events.d/13.per_ip_routing | 4 | ||||
-rwxr-xr-x | ctdb/config/functions | 55 |
3 files changed, 87 insertions, 9 deletions
diff --git a/ctdb/config/README b/ctdb/config/README new file mode 100644 index 0000000000..f2457a7618 --- /dev/null +++ b/ctdb/config/README @@ -0,0 +1,37 @@ +This directory contains run-time support scripts for CTDB. + +Selected highlights: + + ctdb.init + + An initscript for starting ctdbd at boot time. + + events.d/ + + Eventscripts. See events.d/README for more details. + + functions + + Support functions, sourced by eventscripts and other scripts. + + interface_modify.sh + + Script to support add/remove IPs and other funky stuff. Not sure + why this is separate... but it certainly allows easy wrapping by + flock. + + statd-callout + + rpc.statd high-availability callout to support lock migration on + failover. + +Notes: + +* All of these scripts are written in POSIX Bourne shell. Please + avoid bash-isms, including the use of "local" variables (which are + not available in POSIX shell). + +* Do not use absolute paths for commands. Unit tests attempt to + replace many commands with stubs and can not do this if commands are + specified with absolute paths. The functions file controls $PATH so + absolute paths should not be required. diff --git a/ctdb/config/events.d/13.per_ip_routing b/ctdb/config/events.d/13.per_ip_routing index a0df119895..ff4dbdb8c3 100755 --- a/ctdb/config/events.d/13.per_ip_routing +++ b/ctdb/config/events.d/13.per_ip_routing @@ -3,8 +3,10 @@ . $CTDB_BASE/functions loadconfig +ctdb_setup_service_state_dir "per_ip_routing" + [ -z "$CTDB_PER_IP_ROUTING_STATE" ] && { - CTDB_PER_IP_ROUTING_STATE="$CTDB_VARDIR/state/per_ip_routing" + CTDB_PER_IP_ROUTING_STATE="$service_state_dir" } AUTO_LINK_LOCAL="no" diff --git a/ctdb/config/functions b/ctdb/config/functions index 312234546e..32f11f0690 100755 --- a/ctdb/config/functions +++ b/ctdb/config/functions @@ -561,7 +561,48 @@ ctdb_check_counter_equal () { ctdb_status_dir="$CTDB_VARDIR/status" ctdb_fail_dir="$CTDB_VARDIR/failcount" -ctdb_active_dir="$CTDB_VARDIR/active" + +ctdb_setup_service_state_dir () +{ + service_state_dir="$CTDB_VARDIR/state/${1:-${service_name}}" + mkdir -p "$service_state_dir" || { + echo "Error creating state dir \"$service_state_dir\"" + exit 1 + } +} + +######################################################## +# Managed status history, for auto-start/stop + +ctdb_managed_dir="$CTDB_VARDIR/managed_history" + +_ctdb_managed_common () +{ + _service_name="${1:-${service_name}}" + _ctdb_managed_file="$ctdb_managed_dir/$_service_name" +} + +ctdb_service_managed () +{ + _ctdb_managed_common "$@" + mkdir -p "$ctdb_managed_dir" + touch "$_ctdb_managed_file" +} + +ctdb_service_unmanaged () +{ + _ctdb_managed_common "$@" + rm -f "$_ctdb_managed_file" +} + +is_ctdb_previously_managed_service () +{ + _ctdb_managed_common "$@" + [ -f "$_ctdb_managed_file" ] +} + +######################################################## +# Check and set status log_status_cat () { @@ -659,20 +700,18 @@ ctdb_start_stop_service () [ "$event_name" = "monitor" ] || return 0 - _active="$ctdb_active_dir/$_service_name" - if is_ctdb_managed_service "$_service_name"; then - if ! [ -e "$_active" ] ; then + if is_ctdb_managed_service "$_service_name" ; then + if ! is_ctdb_previously_managed_service "$_service_name" ; then echo "Starting service $_service_name" ctdb_service_start || exit $? - mkdir -p "$ctdb_active_dir" - touch "$_active" + ctdb_service_managed "$_service_name" exit 0 fi else - if [ -e "$_active" ] ; then + if is_ctdb_previously_managed_service "$_service_name" ; then echo "Stopping service $_service_name" ctdb_service_stop || exit $? - rm -f "$_active" + ctdb_service_unmanaged "$_service_name" exit 0 fi fi |