fix: reduce phone penalty to 100s, fix shutdown guard race condition

- PHONE_PENALTY_DELAY_PRODUCTION: 600 → 100 seconds
- adjust_shutdown_schedule.sh: write canonical copy before watched config
  to prevent shutdown-schedule-guard.path from restoring stale values
This commit is contained in:
Krzysztof kuhy Rudnicki 2026-03-27 16:13:58 +01:00
parent ccb40ae635
commit ea829c596e
2 changed files with 9 additions and 9 deletions

View File

@ -6,7 +6,7 @@ from pathlib import Path
SICK_LOCKOUT_SECONDS = 120 # 2 minutes wait when sick
PHONE_PENALTY_DELAY_DEMO = 10
PHONE_PENALTY_DELAY_PRODUCTION = 600
PHONE_PENALTY_DELAY_PRODUCTION = 100
ADB_TIMEOUT = 15
STRONGLIFTS_DB_REMOTE = (
"/data/data/com.stronglifts.app/databases/StrongLifts-Database-3"

View File

@ -72,16 +72,16 @@ MORNING_END_HOUR=$3
chattr -i "$CONFIG_FILE" 2>/dev/null || true
chattr -i "$CANONICAL_FILE" 2>/dev/null || true
# Write new config
echo "$NEW_CONFIG" > "$CONFIG_FILE"
# Write canonical copy FIRST (before the watched config) to avoid
# a race with shutdown-schedule-guard.path which triggers on CONFIG_FILE
# changes and restores from CANONICAL_FILE.
echo "$NEW_CONFIG" > "$CANONICAL_FILE"
# Set permissions
chmod 644 "$CONFIG_FILE"
chmod 644 "$CANONICAL_FILE"
# Re-apply immutable attributes
chattr +i "$CONFIG_FILE" || echo "Warning: Could not set immutable on $CONFIG_FILE" >&2
chattr +i "$CANONICAL_FILE" || echo "Warning: Could not set immutable on $CANONICAL_FILE" >&2
# Now write the watched config — guard will see content matches canonical
echo "$NEW_CONFIG" > "$CONFIG_FILE"
chmod 644 "$CONFIG_FILE"
chattr +i "$CONFIG_FILE" || echo "Warning: Could not set immutable on $CONFIG_FILE" >&2
echo "Shutdown schedule updated: Mon-Wed=${1}:00, Thu-Sun=${2}:00, Morning end=${3}:00"