LibrePortal/scripts/config/application/application_menu_apps.sh
librelad 8b14f26125 refactor(desudo): route scattered runtime sudo through privilege helpers
Convert the remaining ad-hoc 'sudo' calls across the data plane to the
run_privileged helpers so every file op lands as the correct owner with
no blanket root:

- DB/configs (manager-owned): db_list_all_apps, delete_db_file,
  install_sqlite, cli_webui_commands -> runInstallOp
- containers (dockerinstall-owned): scan_container_socket, delete_data,
  webui_task_files, webui_app_log, webui_config_patch,
  application_missing_variables, uninstall_app -> runFileOp/runFileWrite
- genuine root: passwd, tailscale, ufw-docker, sysctl grep, systemd
  unit read, authorized_keys read, nobody chown -> runSystem
- interactive editors and 'id -u': drop sudo entirely (run as caller)
- owncloud/adguard container-UID config edits -> runSystem (funnel;
  docker-exec rework deferred)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Signed-off-by: librelad <librelad@digitalangels.vip>
2026-05-24 18:00:19 +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
$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
}