summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2010-12-15 19:19:21 +1100
committerMartin Schwenke <martin@meltin.net>2011-08-11 10:46:20 +1000
commit820d9b30ea9395d0add8b2a0cd56c2246c0aa54e (patch)
treedac4daff4fe52adaba499504a6731223043a668a
parent5b5bd3d27b798a32ebfe147719393f77c1aa145b (diff)
downloadsamba-820d9b30ea9395d0add8b2a0cd56c2246c0aa54e.tar.gz
samba-820d9b30ea9395d0add8b2a0cd56c2246c0aa54e.tar.xz
samba-820d9b30ea9395d0add8b2a0cd56c2246c0aa54e.zip
Eventscripts: rejig the reconfigure infrastructure.
* Add an optional service name argument to existing reconfigure functions. * User function service_reconfigure() instead of variable $service_reconfigure to specify how a service is reconfigured. * New function ctdb_service_check_reconfigure() reconfigures a service if it is flagged for reconfigure. * Remove $service_reconfigure settings from 40.vsftpd and 41.httpd - they're the defaults. Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit 15d4111d0761d82f57d5d4f0b1227812d14e4d7c)
-rwxr-xr-xctdb/config/events.d/40.vsftpd2
-rwxr-xr-xctdb/config/events.d/41.httpd1
-rwxr-xr-xctdb/config/functions46
3 files changed, 36 insertions, 13 deletions
diff --git a/ctdb/config/events.d/40.vsftpd b/ctdb/config/events.d/40.vsftpd
index 8ce2066348..d97dbe9394 100755
--- a/ctdb/config/events.d/40.vsftpd
+++ b/ctdb/config/events.d/40.vsftpd
@@ -14,7 +14,7 @@ service_stop ()
{
service $service_name stop > /dev/null 2>&1
}
-service_reconfigure="service $service_name restart"
+
service_fail_limit=2
service_tcp_ports=21
diff --git a/ctdb/config/events.d/41.httpd b/ctdb/config/events.d/41.httpd
index 1115ba4c2c..87fcdd67ac 100755
--- a/ctdb/config/events.d/41.httpd
+++ b/ctdb/config/events.d/41.httpd
@@ -37,7 +37,6 @@ service_stop ()
service $service_name stop
killall -q -9 $service_name || true
}
-service_reconfigure="service $service_name restart"
loadconfig
diff --git a/ctdb/config/functions b/ctdb/config/functions
index 308781d203..6c9b6caca4 100755
--- a/ctdb/config/functions
+++ b/ctdb/config/functions
@@ -639,35 +639,59 @@ ctdb_setstatus ()
esac
}
+##################################################################
+# Reconfigure a service on demand
+
+_ctdb_service_reconfigure_common ()
+{
+ _d="$ctdb_status_dir/${1:-${service_name}}"
+ mkdir -p "$_d"
+ _ctdb_service_reconfigure_flag="$_d/reconfigure"
+}
+
ctdb_service_needs_reconfigure ()
{
- [ -e "$ctdb_status_dir/$service_name/reconfigure" ]
+ _ctdb_service_reconfigure_common "$@"
+ [ -e "$_ctdb_service_reconfigure_flag" ]
}
ctdb_service_set_reconfigure ()
{
- d="$ctdb_status_dir/$service_name"
- mkdir -p "$d"
- >"$d/reconfigure"
+ _ctdb_service_reconfigure_common "$@"
+ >"$_ctdb_service_reconfigure_flag"
}
ctdb_service_unset_reconfigure ()
{
- rm -f "$ctdb_status_dir/$service_name/reconfigure"
+ _ctdb_service_reconfigure_common "$@"
+ rm -f "$_ctdb_service_reconfigure_flag"
}
ctdb_service_reconfigure ()
{
echo "Reconfiguring service \"$service_name\"..."
- if [ -n "$service_reconfigure" ] ; then
- eval $service_reconfigure
- else
- service "$service_name" restart
+ ctdb_service_unset_reconfigure "$@"
+ service_reconfigure "$@" || return $?
+ ctdb_counter_init "$@"
+}
+
+# Default service_reconfigure() function.
+service_reconfigure ()
+{
+ service "${1:-$service_name}" restart
+}
+
+ctdb_service_check_reconfigure ()
+{
+ if ctdb_service_needs_reconfigure "$@" ; then
+ ctdb_service_reconfigure "$@"
+ exit 0
fi
- ctdb_service_unset_reconfigure
- ctdb_counter_init
}
+##################################################################
+# Does CTDB manage this service? - and associated auto-start/stop
+
ctdb_compat_managed_service ()
{
if [ "$1" = "yes" -a "$2" = "$_service_name" ] ; then