The main sweep — ~260 call sites across ~100 files move from string
concatenation on a single root to appDir/storageAppDirs/storageAppConfigs.
On a single-root install the resolved paths are identical, so this is a
no-op until a location is registered.
Enumerators were the interesting half. `for d in "$containers_dir"/*/`
appears in the menus, the registry/artifact scanners and the DNS setup —
and a shell glob cannot list a rootless 751 tree at all, which is the
same bug config_find_file.sh already documents in a comment. Routing them
through storageAppDirs (which enumerates as the owning user) fixes that
alongside the multi-root work.
Three places needed judgement rather than substitution:
db_app_scan.sh deletes database rows and port allocations for apps whose
folder is missing, and reaps "empty" app dirs. With a storage location
unmounted, every app on it looks exactly like that. Each of those
branches now gates on appStorageAvailable first — an app on an unplugged
drive is skipped with a notice, never deleted.
instance_create.sh rewrites cloned hooks so an instance touches its own
directory instead of the base app's. Its sed matched ${containers_dir}<type>,
which this sweep just replaced with $(appDir <type>) — so it would have
silently stopped redirecting, and an instance would have written to the
original's files (the adguard auth adapter case its own comment warns
about). Now matches both appDir forms, verified against bare, quoted,
unrelated-app, legacy and prose cases.
peer_shell/peer_pull streamed and extracted relative to the primary root.
Both now use the app's own root, and peer_shell keeps a single-root
fallback since it runs as a restricted SSH shell with no LibrePortal env.
Also fixes a pre-existing bug found on the way: webui_app_config.sh
tested "$containers_dir/frontend/data/last_update", one level short of the
real tree under the libreportal app dir, so the WebUI refresh trigger
after a config update has never once fired.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
147 lines
6.5 KiB
Bash
Executable File
147 lines
6.5 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
updateDNS()
|
|
{
|
|
local app_name="$1"
|
|
local flag="$2"
|
|
|
|
if [[ "$OS_TYPE" == "Ubuntu" || "$OS_TYPE" == "Debian" ]]; then
|
|
dnsRemoveNameservers()
|
|
{
|
|
result=$(runResolv clear)
|
|
checkSuccess "Removing all instances of Nameserver from Resolv.conf"
|
|
}
|
|
|
|
if [[ "$flag" == "standalonewireguard" ]]; then
|
|
dnsRemoveNameservers;
|
|
runResolv add "$CFG_DNS_SERVER_1"
|
|
runResolv add "$CFG_DNS_SERVER_2"
|
|
else
|
|
# Check if AdGuard is installed
|
|
local status=$(dockerCheckAppInstalled "adguard" "docker")
|
|
if [ "$status" == "installed" ]; then
|
|
setupDNSIP adguard;
|
|
local adguard_ip="$dns_ip_setup"
|
|
# Testing Docker IP Address
|
|
result=$(ping -c 1 $adguard_ip)
|
|
if [ $? -eq 0 ]; then
|
|
isSuccessful "Ping to $adguard_ip was successful."
|
|
else
|
|
isNotice "Ping to $adguard_ip failed."
|
|
isNotice "Defaulting to DNS 1 Server $CFG_DNS_SERVER_1."
|
|
local adguard_ip="$CFG_DNS_SERVER_1"
|
|
# Fallback to Quad9 if DNS has issues
|
|
result=$(ping -c 1 $adguard_ip)
|
|
if [ $? -eq 0 ]; then
|
|
isSuccessful "Ping to $adguard_ip was successful."
|
|
else
|
|
isNotice "Ping to $adguard_ip failed."
|
|
isNotice "Defaulting to DNS Server 1"
|
|
local adguard_ip="$CFG_DNS_SERVER_1"
|
|
fi
|
|
fi
|
|
else
|
|
local adguard_ip="$CFG_DNS_SERVER_1"
|
|
# Fallback to Quad9 if DNS has issues
|
|
result=$(ping -c 1 $adguard_ip)
|
|
if [ $? -eq 0 ]; then
|
|
isSuccessful "Ping to $adguard_ip was successful."
|
|
else
|
|
isNotice "Ping to $adguard_ip failed."
|
|
isNotice "Defaulting to DNS Server 1"
|
|
local adguard_ip="$CFG_DNS_SERVER_1"
|
|
fi
|
|
fi
|
|
|
|
# Check if Pi-hole is installed
|
|
local status=$(dockerCheckAppInstalled "pihole" "docker")
|
|
if [ "$status" == "installed" ]; then
|
|
setupDNSIP pihole;
|
|
local pihole_ip="$dns_ip_setup"
|
|
# Testing Docker IP Address
|
|
result=$(ping -c 1 $pihole_ip)
|
|
if [ $? -eq 0 ]; then
|
|
isSuccessful "Ping to $pihole_ip was successful."
|
|
else
|
|
isNotice "Ping to $pihole_ip failed."
|
|
isNotice "Defaulting to DNS 2 Server $CFG_DNS_SERVER_2."
|
|
local pihole_ip="$CFG_DNS_SERVER_2"
|
|
# Fallback to Quad9 if DNS has issues
|
|
result=$(ping -c 1 $pihole_ip)
|
|
if [ $? -eq 0 ]; then
|
|
isSuccessful "Ping to $pihole_ip was successful."
|
|
else
|
|
isNotice "Ping to $pihole_ip failed."
|
|
isNotice "Defaulting to DNS Server 2"
|
|
local pihole_ip="$CFG_DNS_SERVER_2"
|
|
fi
|
|
fi
|
|
else
|
|
local pihole_ip="$CFG_DNS_SERVER_2"
|
|
if [ $? -eq 0 ]; then
|
|
isSuccessful "Ping to $pihole_ip was successful."
|
|
else
|
|
isNotice "Ping to $pihole_ip failed."
|
|
isNotice "Defaulting to DNS Server 2"
|
|
local pihole_ip="$CFG_DNS_SERVER_2"
|
|
fi
|
|
fi
|
|
|
|
# Add the custom DNS servers to /etc/resolv.conf
|
|
if [[ "$adguard_ip" == *10.100.0* ]]; then
|
|
# Wireguard update
|
|
local status=$(dockerCheckAppInstalled "wireguard" "docker")
|
|
if [ "$status" == "installed" ]; then
|
|
initializeAppVariables wireguard;
|
|
if [[ $compose_setup == "default" ]]; then
|
|
local compose_file="docker-compose.yml"
|
|
elif [[ $compose_setup == "app" ]]; then
|
|
local compose_file="docker-compose.$app_name.yml"
|
|
fi
|
|
result=$(runFileOp sed -i "s/\(WG_DEFAULT_DNS=\).*/\1$adguard_ip/" $(appDir "$app_name")/$compose_file)
|
|
checkSuccess "Updated Wireguard default DNS to $adguard_ip"
|
|
fi
|
|
dnsRemoveNameservers;
|
|
runResolv add "$adguard_ip"
|
|
runResolv add "$pihole_ip"
|
|
elif [[ "$pihole_ip" == *10.100.0* ]]; then
|
|
# Wireguard update
|
|
local status=$(dockerCheckAppInstalled "wireguard" "docker")
|
|
if [ "$status" == "installed" ]; then
|
|
initializeAppVariables $app_name;
|
|
if [[ $compose_setup == "default" ]]; then
|
|
local compose_file="docker-compose.yml"
|
|
elif [[ $compose_setup == "app" ]]; then
|
|
local compose_file="docker-compose.$app_name.yml"
|
|
fi
|
|
result=$(runFileOp sed -i "s/\(WG_DEFAULT_DNS=\).*/\1$pihole_ip/" $(appDir "$app_name")/$compose_file)
|
|
checkSuccess "Updated Wireguard default DNS to $pihole_ip"
|
|
fi
|
|
dnsRemoveNameservers;
|
|
runResolv add "$pihole_ip"
|
|
runResolv add "$adguard_ip"
|
|
else
|
|
# Wireguard update
|
|
local status=$(dockerCheckAppInstalled "wireguard" "docker")
|
|
if [ "$status" == "installed" ]; then
|
|
initializeAppVariables wireguard;
|
|
if [[ $compose_setup == "default" ]]; then
|
|
local compose_file="docker-compose.yml"
|
|
elif [[ $compose_setup == "app" ]]; then
|
|
local compose_file="docker-compose.$app_name.yml"
|
|
fi
|
|
result=$(runFileOp sed -i "s/\(WG_DEFAULT_DNS=\).*/\1$adguard_ip/" $(appDir "$app_name")/$compose_file)
|
|
checkSuccess "Updated Wireguard default DNS to $adguard_ip"
|
|
fi
|
|
dnsRemoveNameservers;
|
|
runResolv add "$adguard_ip"
|
|
runResolv add "$pihole_ip"
|
|
fi
|
|
if [ "$flag" == "install" ]; then
|
|
initializeAppVariables $app_name;
|
|
fi
|
|
isSuccessful "Resolv.conf has been updated with the latest DNS settings."
|
|
fi
|
|
fi
|
|
}
|