LibrePortal/scripts/config/application/application_menu_apps.sh
librelad 4ce0340ef8 refactor(backup): replace per-app cron stagger with task-queue scheduler
Application backups were driven by one crontab entry per app, each offset by
id * CFG_BACKUP_CRONTAB_APP_INTERVAL minutes. That minute offset is written
straight into cron's 0-59 minute field, so past ~20 apps it overflowed into
an invalid entry that silently never fired, and the fixed spacing could not
serialize backups that ran longer than the gap.

Replace it with a single daily entry (`libreportal backup scheduled`) that
enqueues a backup task per enabled app. The existing systemd task processor
drains them serially — no minute overflow, real serialization, and backups
are now visible/cancellable in the Tasks UI. Per-app enable is read from
CFG_<APP>_BACKUP at schedule time instead of being mirrored into crontab.

Removes the stagger machinery (timing/setup/check/remove scripts), the
now-unused cron_jobs table + insert, and the CFG_BACKUP_CRONTAB_APP_INTERVAL
config knob and its WebUI field.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Signed-off-by: librelad <librelad@digitalangels.vip>
2026-05-22 14:34:35 +01:00

69 lines
2.4 KiB
Bash
Executable File

#!/bin/bash
viewAppConfigs()
{
while true; do
isHeader "Installed Applications"
# Get all installed apps from containers directory
local installed_apps=()
for app_dir in "$containers_dir"/*/; do
if [ -d "$app_dir" ]; then
local app_name=$(basename "$app_dir")
installed_apps+=("$app_name")
fi
done
if [ ${#installed_apps[@]} -eq 0 ]; then
isNotice "No installed applications found."
fi
# Display all installed apps with numbers
for ((i = 0; i < ${#installed_apps[@]}; i++)); do
local app_name="${installed_apps[i]}"
isOption "$((i + 1)). $app_name"
done
echo ""
isOption "x. Exit"
echo ""
isQuestion "Enter app number to configure (or x to exit): "
read -p "" selected_app_number
if [[ "$selected_app_number" == "x" ]]; then
if [[ $config_edited == "true" ]]; then
echo ""
isNotice "Reloading configuration file(s) for Applications."
echo ""
sourceScanFiles "app_configs"
else
isNotice "Exiting..."
echo ""
checkConfigFilesMissingVariables true
crontabSetupBackupScheduler
fi
elif [[ "$selected_app_number" =~ ^[0-9]+$ ]] && [ "$selected_app_number" -ge 1 ] && [ "$selected_app_number" -le ${#installed_apps[@]} ]; then
local index=$((selected_app_number - 1))
local selected_app="${installed_apps[index]}"
# Get the config file for this app
local config_file="$containers_dir/${selected_app}/${selected_app}.config"
if [ -f "$config_file" ]; then
sudo $CFG_TEXT_EDITOR "$config_file"
createTouch "$config_file" $sudo_user_name
echo ""
isNotice "Configuration file for '$selected_app' has been updated."
echo ""
else
isNotice "Configuration file for '$selected_app' not found."
echo ""
fi
else
isNotice "Invalid input. Please enter a valid number or 'x' to exit."
echo ""
read -p "Press Enter to continue."
fi
done
}