Merge claude/1

This commit is contained in:
librelad 2026-06-02 15:02:36 +01:00
commit 287c13a311

View File

@ -1,34 +1,50 @@
#!/bin/bash #!/bin/bash
installDockerNetwork() installDockerNetwork()
{ {
# Check if network setup is needed if [[ "$DOCKER_NETWORK_SETUP_NEEDED" != "true" ]]; then
if [[ "$DOCKER_NETWORK_SETUP_NEEDED" == "true" ]]; then isNotice "Docker network $CFG_NETWORK_NAME already exists or setup not needed"
isHeader "Create a Docker Network" return 0
fi
isNotice "Network $CFG_NETWORK_NAME not found, creating now" isHeader "Create a Docker Network"
# Check if we need to generate a new subnet # Re-check existence right before creating, and converge instead of erroring
updateDockerNetworkSubnet # if it's already there. The requirement check that set
# DOCKER_NETWORK_SETUP_NEEDED can run before the rootless daemon socket is
# reachable (a failed inspect is indistinguishable from "network absent"), and
# a previous install leaves the network behind — both make us think it's new
# when it isn't. If it exists, leave it in place and adopt its real subnet so
# CFG stays in step with docker (and we don't randomize to a subnet we can't apply).
if dockerCommandRun "docker network inspect $CFG_NETWORK_NAME > /dev/null 2>&1"; then
local current_subnet; current_subnet=$(dockerCommandRun "docker network inspect $CFG_NETWORK_NAME --format '{{range .IPAM.Config}}{{.Subnet}}{{end}}' 2>/dev/null")
isNotice "Docker network $CFG_NETWORK_NAME already exists, leaving it in place"
if [[ -n "$current_subnet" && "$current_subnet" != "$CFG_NETWORK_SUBNET" ]]; then
adoptDockerSubnet "$current_subnet"
fi
return 0
fi
# Create the Docker network command isNotice "Network $CFG_NETWORK_NAME not found, creating now"
local network_create="docker network create \
# Check if we need to generate a new subnet
updateDockerNetworkSubnet
# Create the Docker network command
local network_create="docker network create \
--driver=bridge \ --driver=bridge \
--subnet=$CFG_NETWORK_SUBNET \ --subnet=$CFG_NETWORK_SUBNET \
--ip-range=${CFG_NETWORK_SUBNET%.*}.0/24 \ --ip-range=${CFG_NETWORK_SUBNET%.*}.0/24 \
--gateway=${CFG_NETWORK_SUBNET%.*}.1 \ --gateway=${CFG_NETWORK_SUBNET%.*}.1 \
--opt com.docker.network.bridge.name=$CFG_NETWORK_NAME \ --opt com.docker.network.bridge.name=$CFG_NETWORK_NAME \
$CFG_NETWORK_NAME" $CFG_NETWORK_NAME"
# Run the network creation command # Run the network creation command
local result; result=$(dockerCommandRun "$network_create") local result; result=$(dockerCommandRun "$network_create")
if [[ $? -eq 0 ]]; then if [[ $? -eq 0 ]]; then
checkSuccess "Docker network $CFG_NETWORK_NAME created successfully" checkSuccess "Docker network $CFG_NETWORK_NAME created successfully"
else
isError "Failed to create Docker network $CFG_NETWORK_NAME"
isError " $result"
fi
else else
isNotice "Docker network $CFG_NETWORK_NAME already exists or setup not needed" isError "Failed to create Docker network $CFG_NETWORK_NAME"
isError " $result"
fi fi
} }