The migrate/ helpers were either uncallable or no-ops: - migrateAppsToNewNetwork + updateComposeFileNetwork: never called from anywhere. The intended sed-on-compose subnet rewrite would also have fought the tag system / network_resources DB. - checkAppNetworkCompatibility: called from updateDockerNetworkConfig as a gate, but never explicitly returns, so it's effectively always-true and both branches do the same work. Pure noise. - getInstalledApps: only used by the above. - updateDockerNetworkConfig: collapses to a 2-line 'CFG := docker's reported subnet' adoption — inlined into check_docker_network.sh as adoptDockerSubnet(), which is what it actually does. The legitimate 'subnet changed, refresh apps' path is already covered by the idempotent per-app reinstall (dockerInstallApp ... reset_network=true → clears DB allocations → installer re-runs → ipUpdateComposeTags picks fresh IPs from the current CFG_NETWORK_SUBNET). Migration (infrastructure regen) vs restore (data) stays clean: reinstall regenerates compose+IPs, restore lays data on top. No new pathway needed. Files dropped: scripts/docker/network/migrate/migrate_apps_to_new_network.sh scripts/docker/network/migrate/migrate_check_app_network_compatibility.sh scripts/docker/network/migrate/migrate_get_installed_apps.sh scripts/docker/network/migrate/migrate_update_compose_file_network.sh scripts/docker/network/migrate/migrate_update_docker_network_config.sh Plus the now-empty migrate/ subdir; files_docker.sh regenerated to drop the references. Signed-off-by: librelad <librelad@digitalangels.vip>
52 lines
2.0 KiB
Bash
Executable File
52 lines
2.0 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# CFG↔docker subnet adoption: if the docker network already exists with a
|
|
# different /24 than CFG, treat docker's value as the truth and update CFG.
|
|
# Apps' allocated IPs are still inside docker's subnet, so nothing else needs
|
|
# re-IPing. (A genuine user-initiated subnet change is a `libreportal app
|
|
# install <name> --reset-network` per app — fresh compose + fresh IPs from
|
|
# the new subnet via the standard idempotent install path.)
|
|
adoptDockerSubnet()
|
|
{
|
|
local current_subnet="$1"
|
|
[[ -z "$current_subnet" ]] && return 0
|
|
updateConfigOption "CFG_NETWORK_SUBNET" "$current_subnet"
|
|
CFG_NETWORK_SUBNET="$current_subnet"
|
|
isSuccessful "Adopted docker's subnet into CFG: $current_subnet"
|
|
}
|
|
|
|
checkDockerNetworkRequirement()
|
|
{
|
|
if [[ $CFG_REQUIREMENT_DOCKER_NETWORK == "true" ]]; then
|
|
if [[ $CFG_DOCKER_INSTALL_TYPE == "rootless" ]]; then
|
|
if dockerCommandRun "docker network inspect $CFG_NETWORK_NAME > /dev/null 2>&1"; then
|
|
local current_subnet=$(dockerCommandRun "docker network inspect $CFG_NETWORK_NAME --format '{{range .IPAM.Config}}{{.Subnet}}{{end}}' 2>/dev/null")
|
|
|
|
if [[ "$current_subnet" == "$CFG_NETWORK_SUBNET" ]]; then
|
|
isSuccessful "Docker Network $CFG_NETWORK_NAME exists with matching subnet"
|
|
else
|
|
adoptDockerSubnet "$current_subnet"
|
|
fi
|
|
else
|
|
isNotice "Docker Network $CFG_NETWORK_NAME not found."
|
|
DOCKER_NETWORK_SETUP_NEEDED="true"
|
|
((preinstallneeded++))
|
|
fi
|
|
elif [[ $CFG_DOCKER_INSTALL_TYPE == "rooted" ]]; then
|
|
if runFileOp docker network inspect $CFG_NETWORK_NAME > /dev/null 2>&1; then
|
|
local current_subnet=$(runFileOp docker network inspect $CFG_NETWORK_NAME --format '{{range .IPAM.Config}}{{.Subnet}}{{end}}' 2>/dev/null)
|
|
|
|
if [[ "$current_subnet" == "$CFG_NETWORK_SUBNET" ]]; then
|
|
isSuccessful "Docker Network $CFG_NETWORK_NAME exists with matching subnet"
|
|
else
|
|
adoptDockerSubnet "$current_subnet"
|
|
fi
|
|
else
|
|
isNotice "Docker Network $CFG_NETWORK_NAME not found."
|
|
DOCKER_NETWORK_SETUP_NEEDED="true"
|
|
((preinstallneeded++))
|
|
fi
|
|
fi
|
|
fi
|
|
}
|