#!/bin/bash
# Varaverk: run array_stopping.sh on array stop (foreground — blocks until done).
# Direct bash call to avoid PHP/scheduler chain failing silently at shutdown time.
SCRIPTS_DIR="/boot/config/plugins/varaverk"
cfg="$SCRIPTS_DIR/varaverk.cfg"
[[ -f "$cfg" ]] && _sd=$(grep -oP '(?<=^SCRIPTS_DIR=")[^"]+' "$cfg" 2>/dev/null) && [[ -n "$_sd" ]] && SCRIPTS_DIR="$_sd"
runner="$SCRIPTS_DIR/Plugin/unraid/run_job.sh"
script="$SCRIPTS_DIR/Orchestrators/array_stopping.sh"
[[ -f "$script" ]] && bash "$runner" "Orchestrators/array_stopping.sh" "$script"
