LibrePortal/scripts/config/application/application_edit_config.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

63 lines
2.1 KiB
Bash
Executable File

#!/bin/bash
editAppConfig()
{
local app_name="$1"
local config_file
local app_dir
if [[ "$app_name" == "" ]]; then
isError " app_name is required"
exit 1
fi
# Use find to search for the app_name folder within $containers_dir
local app_dir=$containers_dir$app_name
if [ -n "$app_dir" ]; then
local config_file="$app_dir/$app_name.config"
if [ -f "$config_file" ]; then
# Calculate the checksum of the original file
local original_checksum=$(md5sum "$config_file")
# Open the file with $CFG_TEXT_EDITOR for editing
$CFG_TEXT_EDITOR "$config_file"
# Calculate the checksum of the edited file
local edited_checksum=$(md5sum "$config_file")
# Compare the checksums to check if changes were made
if [[ "$original_checksum" != "$edited_checksum" ]]; then
source $config_file
#cat $config_file
# Ask the user if they want to reinstall the application
isHeader "App Config Changes Found"
while true; do
echo ""
isNotice "Changes have been made to the $app_name configuration."
echo ""
isQuestion "Would you like to reinstall $app_name? (y/n): "
read -p "" reinstall_choice
if [[ -n "$reinstall_choice" ]]; then
break
fi
isNotice "Please provide a valid input."
done
if [[ "$reinstall_choice" =~ [yY] ]]; then
# Run to see if edits have removed any variables
checkConfigFilesMissingVariables;
# Convert the first letter of app_name to uppercase
dockerInstallApp $app_name;
fi
else
isNotice "No changes were made to the $app_name configuration."
fi
else
echo "Config file not found for $app_name."
fi
else
echo "App folder not found for $app_name."
fi
}