ctdb-scripts: Fetch recovery lock option from config file in 01.reclock
[metze/samba/wip.git] / ctdb / config / events.d / 01.reclock
index 45b2405ce94c78865f35f4b6bef74651e92b7dbe..e14d8c22f488576b300f7f22ce91f17241687cc2 100755 (executable)
@@ -6,7 +6,27 @@
 
 . "${CTDB_BASE}/functions"
 
-loadconfig
+load_script_options
+
+ctdb_setup_state_dir "service" "reclock"
+
+ctdb_get_reclock_option ()
+{
+       _reclock_opt_file="${CTDB_SCRIPT_VARDIR}/recovery_lock.cache"
+
+       if [ -f "$_reclock_opt_file" ] ; then
+               . "$_reclock_opt_file"
+               return
+       fi
+
+       ctdb_translate_option "cluster" \
+                             "recovery lock" \
+                             "CTDB_RECOVERY_LOCK" >"$_reclock_opt_file"
+
+       . "$_reclock_opt_file"
+}
+
+ctdb_get_reclock_option
 
 # If CTDB_RECOVERY_LOCK specifies a helper then exit because this
 # script can't do anything useful.
@@ -38,14 +58,16 @@ monitor)
        ) >/dev/null 2>&1 &
 
        ctdb_counter_incr
-       if ! ctdb_check_counter "quiet" -ge 200 ; then
+       num_fails=$(ctdb_counter_get)
+       if [ "$num_fails" -ge 200 ] ; then
            echo "Reclock file \"$CTDB_RECOVERY_LOCK\" can not be accessed. Shutting down."
            df
            sleep 1
            $CTDB shutdown
+           exit 1
+       elif [ "$num_fails" -ge 4 ] ; then
+               die "ERROR: ${num_fails} consecutive failures checking reclock"
        fi
-
-       ctdb_check_counter "error" -gt 3
        ;;
 esac