Merge claude/2
This commit is contained in:
commit
baf1500cb7
@ -1,5 +1,20 @@
|
||||
#!/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
|
||||
@ -10,7 +25,7 @@ checkDockerNetworkRequirement()
|
||||
if [[ "$current_subnet" == "$CFG_NETWORK_SUBNET" ]]; then
|
||||
isSuccessful "Docker Network $CFG_NETWORK_NAME exists with matching subnet"
|
||||
else
|
||||
updateDockerNetworkConfig "$current_subnet"
|
||||
adoptDockerSubnet "$current_subnet"
|
||||
fi
|
||||
else
|
||||
isNotice "Docker Network $CFG_NETWORK_NAME not found."
|
||||
@ -24,7 +39,7 @@ checkDockerNetworkRequirement()
|
||||
if [[ "$current_subnet" == "$CFG_NETWORK_SUBNET" ]]; then
|
||||
isSuccessful "Docker Network $CFG_NETWORK_NAME exists with matching subnet"
|
||||
else
|
||||
updateDockerNetworkConfig "$current_subnet"
|
||||
adoptDockerSubnet "$current_subnet"
|
||||
fi
|
||||
else
|
||||
isNotice "Docker Network $CFG_NETWORK_NAME not found."
|
||||
|
||||
@ -1,68 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
migrateAppsToNewNetwork()
|
||||
{
|
||||
local old_subnet="$1"
|
||||
local new_subnet="$2"
|
||||
|
||||
if [[ -z "$old_subnet" || -z "$new_subnet" ]]; then
|
||||
isError "Both old and new subnets required for network migration"
|
||||
fi
|
||||
|
||||
isNotice "Starting network migration from $old_subnet to $new_subnet"
|
||||
isNotice "This will update all installed applications to use the new network."
|
||||
echo ""
|
||||
|
||||
# Get list of installed apps
|
||||
local installed_apps=$(getInstalledApps)
|
||||
|
||||
if [[ -z "$installed_apps" ]]; then
|
||||
isNotice "No installed applications found for migration"
|
||||
fi
|
||||
|
||||
local apps_updated=0
|
||||
local apps_failed=0
|
||||
|
||||
for app_name in $installed_apps; do
|
||||
echo ""
|
||||
isNotice "Processing $app_name..."
|
||||
|
||||
# Get app's compose file path
|
||||
local compose_file="$containers_dir/$app_name/compose.yml"
|
||||
|
||||
if [[ ! -f "$compose_file" ]]; then
|
||||
isNotice " No compose file found for $app_name, skipping"
|
||||
continue
|
||||
fi
|
||||
|
||||
# Backup original compose file
|
||||
cp "$compose_file" "$compose_file.backup.$(date +%s)"
|
||||
|
||||
# Update network references in compose file
|
||||
if updateComposeFileNetwork "$compose_file" "$old_subnet" "$new_subnet"; then
|
||||
# Restart the app to apply changes
|
||||
isNotice " Restarting $app_name to apply network changes..."
|
||||
|
||||
if dockerCommandRun "cd $containers_dir/$app_name && docker compose down" && \
|
||||
dockerCommandRun "cd $containers_dir/$app_name && COMPOSE_PROGRESS=plain docker compose up --quiet-pull -d"; then
|
||||
isSuccessful " $app_name successfully migrated to new network"
|
||||
((apps_updated++))
|
||||
else
|
||||
isError "Failed to restart $app_name after network update"
|
||||
# Restore backup
|
||||
mv "$compose_file.backup.$(date +%s)" "$compose_file"
|
||||
((apps_failed++))
|
||||
fi
|
||||
else
|
||||
isError "Failed to update compose file for $app_name"
|
||||
((apps_failed++))
|
||||
fi
|
||||
done
|
||||
|
||||
echo ""
|
||||
isSuccessful "Network migration completed:"
|
||||
isSuccessful " Apps updated: $apps_updated"
|
||||
if [[ $apps_failed -gt 0 ]]; then
|
||||
isError "Apps failed: $apps_failed"
|
||||
fi
|
||||
}
|
||||
@ -1,42 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
checkAppNetworkCompatibility()
|
||||
{
|
||||
local target_subnet="$1"
|
||||
local target_base="${target_subnet%/*}"
|
||||
|
||||
# Get list of installed apps
|
||||
local installed_apps=$(getInstalledApps)
|
||||
|
||||
if [[ -z "$installed_apps" ]]; then
|
||||
:
|
||||
fi
|
||||
|
||||
local incompatible_apps=0
|
||||
|
||||
for app_name in $installed_apps; do
|
||||
local compose_file="$containers_dir/$app_name/compose.yml"
|
||||
|
||||
if [[ -f "$compose_file" ]]; then
|
||||
# Check for static IP assignments that might be incompatible
|
||||
local static_ips=$(grep -E "ipv4_addresses:|ip:" "$compose_file" 2>/dev/null)
|
||||
|
||||
if [[ -n "$static_ips" ]]; then
|
||||
# Check if any IPs are outside the target subnet range
|
||||
while read -r ip_line; do
|
||||
local ip=$(echo "$ip_line" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' | head -1)
|
||||
if [[ -n "$ip" && ! "$ip" =~ ^${target_base%.*} ]]; then
|
||||
isNotice " $app_name has incompatible IP: $ip (target: $target_base.0/24)"
|
||||
((incompatible_apps++))
|
||||
fi
|
||||
done <<< "$static_ips"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ $incompatible_apps -gt 0 ]]; then
|
||||
isNotice "Found $incompatible_apps apps with network settings that may need updating"
|
||||
else
|
||||
:
|
||||
fi
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
getInstalledApps()
|
||||
{
|
||||
# Get list of directories in containers that have compose files
|
||||
local apps=""
|
||||
for dir in "$containers_dir"/*; do
|
||||
if [[ -d "$dir" && -f "$dir/compose.yml" ]]; then
|
||||
local app_name=$(basename "$dir")
|
||||
apps="$apps $app_name"
|
||||
fi
|
||||
done
|
||||
echo "$apps"
|
||||
}
|
||||
@ -1,27 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
updateComposeFileNetwork()
|
||||
{
|
||||
local compose_file="$1"
|
||||
local old_subnet="$2"
|
||||
local new_subnet="$3"
|
||||
|
||||
# Update network subnet references
|
||||
sed -i "s|subnet: $old_subnet|subnet: $new_subnet|g" "$compose_file"
|
||||
|
||||
# Update IP range references
|
||||
local old_ip_range="${old_subnet%.*}.0/24"
|
||||
local new_ip_range="${new_subnet%.*}.0/24"
|
||||
sed -i "s|ip-range: $old_ip_range|ip-range: $new_ip_range|g" "$compose_file"
|
||||
|
||||
# Update gateway references
|
||||
local old_gateway="${old_subnet%.*}.1"
|
||||
local new_gateway="${new_subnet%.*}.1"
|
||||
sed -i "s|gateway: $old_gateway|gateway: $new_gateway|g" "$compose_file"
|
||||
|
||||
# Update static IP assignments if any
|
||||
local old_network_base="${old_subnet%/*}"
|
||||
local new_network_base="${new_subnet%/*}"
|
||||
sed -i "s|$old_network_base\.|$new_network_base\.|g" "$compose_file"
|
||||
|
||||
}
|
||||
@ -1,23 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
updateDockerNetworkConfig()
|
||||
{
|
||||
local new_subnet="$1"
|
||||
|
||||
if [[ -z "$new_subnet" ]]; then
|
||||
isNotice "No subnet provided to Update Network Config. Skipping..."
|
||||
else
|
||||
if checkAppNetworkCompatibility "$new_subnet"; then
|
||||
updateConfigOption "CFG_NETWORK_SUBNET" "$new_subnet"
|
||||
checkSuccess "Updated network configuration to: $new_subnet"
|
||||
CFG_NETWORK_SUBNET="$new_subnet"
|
||||
isSuccessful "Network configuration updated successfully."
|
||||
else
|
||||
isNotice "App network assignments need to be updated for the new subnet."
|
||||
updateConfigOption "CFG_NETWORK_SUBNET" "$new_subnet"
|
||||
checkSuccess "Updated network configuration to: $new_subnet"
|
||||
CFG_NETWORK_SUBNET="$new_subnet"
|
||||
isNotice "Note: You may need to reinstall applications to ensure proper network connectivity."
|
||||
fi
|
||||
fi
|
||||
}
|
||||
@ -43,11 +43,6 @@ docker_scripts=(
|
||||
"docker/install/rootless/rootless_start_setup.sh"
|
||||
"docker/install/rootless/rootless_uninstall.sh"
|
||||
"docker/install/rootless/rootless_user.sh"
|
||||
"docker/network/migrate/migrate_apps_to_new_network.sh"
|
||||
"docker/network/migrate/migrate_check_app_network_compatibility.sh"
|
||||
"docker/network/migrate/migrate_get_installed_apps.sh"
|
||||
"docker/network/migrate/migrate_update_compose_file_network.sh"
|
||||
"docker/network/migrate/migrate_update_docker_network_config.sh"
|
||||
"docker/network/network_prune.sh"
|
||||
"docker/network/network_randomize_subnet.sh"
|
||||
"docker/network/network_setup.sh"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user