LibrePortal/scripts/network/traefik/traefik_whitelist.sh
librelad 875a60f90f LibrePortal v0.1.0 — initial release
A free, open, self-hosted app platform (GNU AGPLv3): one-click app deploys,
Traefik reverse proxy with automatic SSL, rootless Docker support, gluetun
VPN routing, and a web dashboard to manage it all.

Free & open forever to self-host; optional paid hosted services fund it.
See PROMISE.md.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

Signed-off-by: librelad <librelad@digitalangels.vip>
2026-05-21 20:37:54 +01:00

29 lines
870 B
Bash
Executable File

#!/bin/bash
traefikUpdateWhitelist()
{
local whitelist_file="${containers_dir}traefik/etc/dynamic/whitelist.yml"
if [ -f "$whitelist_file" ]; then
# Split the CFG_IPS_WHITELIST into an array
IFS=',' read -ra IP_ARRAY <<< "$CFG_IPS_WHITELIST"
# Build the YAML content dynamically
YAML_CONTENT="http:
middlewares:
global-ipwhitelist:
ipWhiteList:
sourceRange:"
for IP in "${IP_ARRAY[@]}"; do
YAML_CONTENT+="\n - \"$IP\""
done
# Add CFG_NETWORK_SUBNET to the YAML content
YAML_CONTENT+="\n - \"$CFG_NETWORK_SUBNET\""
# Now update the YAML file with the new content using sudo
echo -e "$YAML_CONTENT" | sudo tee "$whitelist_file" > /dev/null
isSuccessful "Traefik has been updated with the latest whitelist IPs."
fi
}