Fix dead-variable and exit-code bugs found in codebase-wide audit
Same audit as the orchestrator standardization pass (2a062e5), extended to
every remaining script. Found the same class of bug independently recurring:
ramdisk_stop.sh checked $LOG (nothing assigns it, should be $ENABLE_LOGGING),
partnership_onboard.sh checked $LOG_MODE (same issue), emby_session_report.sh
checked $TRANSCODE_PCT which was never computed so the high-transcode alert
could never fire, and storage_migrate.sh never called detect_hosts() so
$MY_ID was empty, silently breaking the post-migration host*.conf update.
partnership_manager.sh used `local` at top-level script scope (invalid outside
a function) and had two master.conf path references missing "Configurations/".
Along the way: several scripts (share_setup.sh, conf_sync.sh,
downloaders_reset.sh, transcode_cleanup.sh, transcode_manager.sh,
remote_arr_cache_writer.sh, upgrade_webhook_handler.sh) had no explicit
trailing exit code, so they always reported success regardless of real
failures. play_state_sync.sh was missing the partnership gate its own header
documented, so remote play-state sync ran even with PARTNERSHIP_ENABLED=false;
it also always exited 0 on sync errors. arr_profile_enforcer.sh and
webhook_setup.sh hand-rolled their own flag parsing instead of common.sh's
parse_args, so --log silently did nothing on either.
system_watchdog.sh was itself an un-standardized mini-orchestrator — converted
to the shared run_orch_child()/JOB_PASS/JOB_FAIL pattern, added the missing
failure notification, and fixed dry-run to pass --dry-run down to children
instead of skipping them outright. Also fixed a stale webgui_watchdog.sh path
in master.conf.template that would break system_watchdog.sh on any fresh
install.
Closed a sibling-drift gap: radarr_cleanup.sh and sonarr_cleanup.sh were
missing lidarr_cleanup.sh's tracked-count percentage-drop safety gate and its
"not configured on this host, skip cleanly" guard — both now match Lidarr's
7-gate model.
This commit is contained in:
@@ -764,7 +764,7 @@ provision_emby_admin() {
|
||||
error "Emby username '${username}' is already taken on the shared instance"
|
||||
error "Options:"
|
||||
error " 1. Sign in with that account — it may already be yours"
|
||||
error " 2. Set a different name in ${user_var} and re-run --onboard"
|
||||
error " 2. Set a different name in HOST${MIRROR_ID: -1}_PARTNERSHIP_EMBY_ADMIN_USER and re-run --onboard"
|
||||
return 1
|
||||
fi
|
||||
|
||||
@@ -916,7 +916,7 @@ do_final_sync() {
|
||||
# Safe master.conf modification with error handling
|
||||
update_master_conf() {
|
||||
local key="$1" value="$2"
|
||||
local conf="$SCRIPT_DIR/../master.conf"
|
||||
local conf="$CONF_DIR/master.conf"
|
||||
if [[ ! -f "$conf" ]]; then
|
||||
error "master.conf not found at $conf"
|
||||
return 1
|
||||
@@ -1162,7 +1162,7 @@ if [[ "$MODE" == "onboard" ]]; then
|
||||
echo ""
|
||||
echo "Enabling partnership in master.conf..."
|
||||
if [[ "$DRY_RUN" == false ]]; then
|
||||
local _master_conf="${SCRIPTS_ROOT:-$(dirname "$SCRIPT_DIR")}/master.conf"
|
||||
_master_conf="$CONF_DIR/master.conf"
|
||||
if grep -q "^[[:space:]]*PARTNERSHIP_ENABLED=" "$_master_conf" 2>/dev/null; then
|
||||
sed -i "s|^[[:space:]]*PARTNERSHIP_ENABLED=.*|PARTNERSHIP_ENABLED=true|" "$_master_conf"
|
||||
else
|
||||
|
||||
@@ -240,7 +240,7 @@ AM_MIRROR=false
|
||||
|
||||
EXTRA_FLAGS=()
|
||||
[[ "$DRY_RUN" == true ]] && EXTRA_FLAGS+=("--dry-run")
|
||||
[[ "$LOG_MODE" == true ]] && EXTRA_FLAGS+=("--log")
|
||||
[[ "$ENABLE_LOGGING" == true ]] && EXTRA_FLAGS+=("--log")
|
||||
|
||||
START=$(date +%s)
|
||||
|
||||
@@ -718,7 +718,7 @@ else
|
||||
_rsync_script="$SCRIPTS_ROOT/Rsync/rsync.sh"
|
||||
_seed_flags=(--seed)
|
||||
[[ "$DRY_RUN" == true ]] && _seed_flags+=(--dry-run)
|
||||
[[ "$LOG_MODE" == true ]] && _seed_flags+=(--log)
|
||||
[[ "$ENABLE_LOGGING" == true ]] && _seed_flags+=(--log)
|
||||
for _share in "${DAILY_SYNC_SHARES[@]}"; do
|
||||
echo " Seeding: $_share"
|
||||
if bash "$_rsync_script" "$_share" "${_seed_flags[@]}"; then
|
||||
|
||||
@@ -175,3 +175,5 @@ done
|
||||
echo ""
|
||||
echo " Shares: $CREATED created, $SKIPPED already existed on $MIRROR"
|
||||
[[ "$DRY_RUN" == true ]] && echo " (dry-run — nothing written)"
|
||||
|
||||
exit 0
|
||||
|
||||
Reference in New Issue
Block a user