Update README and rotate script to clarify container restart order and improve handling of additional restart containers
Build and Push Docker Images / build-and-push (push) Successful in 39s

This commit is contained in:
2026-06-05 18:22:04 +02:00
parent 34ee842d34
commit 86360ec066
2 changed files with 26 additions and 12 deletions
@@ -31,8 +31,8 @@ docker run --rm --entrypoint pia-wg-config bramkel/gluetun-pia-wireguard-rotator
| Variable | Default | Description |
|----------|---------|-------------|
| `RESTART_CONTAINERS` | — | CSV of JSON-array met containers om te herstarten, **in volgorde** (gluetun eerst, daarna sidecars). Voorbeeld: `m3u-filter-vpn,m3u-editor,xtream-proxy` |
| `GLUETUN_CONTAINER` | `m3u-filter-vpn` | Alleen gebruikt als `RESTART_CONTAINERS` leeg is |
| `RESTART_CONTAINERS` | — | CSV of JSON-array met **extra** containers om te herstarten na gluetun (sidecars). Voorbeeld: `SabNZBd,qbittorrent,Spotweb` |
| `GLUETUN_CONTAINER` | `m3u-filter-vpn` | Gluetun-container; wordt **altijd als eerste** herstart |
| `WG_CONFIG_PATH` | `/config/wireguard/wg0.conf` | Pad waar `wg0.conf` wordt geschreven |
| `ROTATOR_STATE_PATH` | `/config/rotator-state.json` | Laatste rotatie-metadata |
| `ROTATE_AT` | `03:00` | Dagelijks rotatietijdstip (`HH:MM`, in `TZ`) |
@@ -59,7 +59,8 @@ Zie [`docker-compose.example.yml`](docker-compose.example.yml) voor een volledig
- PIA_USER=${PIA_USER}
- PIA_PASS=${PIA_PASSWORD}
- PIA_REGIONS=netherlands,france,belgium
- RESTART_CONTAINERS=m3u-filter-vpn,m3u-editor,xtream-proxy
- GLUETUN_CONTAINER=downloaders-vpn
- RESTART_CONTAINERS=SabNZBd,qbittorrent,nzbhydra2,Spotweb
- ROTATE_AT=03:00
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
@@ -100,9 +101,9 @@ Optioneel host-`.env`-keys (`WIREGUARD_*`) opruimen als die niet meer gebruikt w
1. Bij start: direct roteren (nieuwe config + container-restarts)
2. Daarna: elke dag om `ROTATE_AT` opnieuw
3. Willekeurige region uit `PIA_REGIONS`
4. Containers uit `RESTART_CONTAINERS` worden één voor één herstart in de opgegeven volgorde
4. `GLUETUN_CONTAINER` wordt altijd als eerste herstart, daarna containers uit `RESTART_CONTAINERS`
**Let op:** zet gluetun altijd als eerste in `RESTART_CONTAINERS`. Sidecars met `network_mode: service:...` herstarten pas daarna, zodat ze opnieuw aan de VPN-namespace koppelen.
**Let op:** zet gluetun **niet** in `RESTART_CONTAINERS`; gebruik `GLUETUN_CONTAINER` daarvoor. Sidecars met `network_mode: service:...` horen in `RESTART_CONTAINERS`.
**Let op:** elke rotatie veroorzaakt kort downtime voor alle VPN-afhankelijke services.
@@ -41,14 +41,10 @@ pick_random_region() {
printf '%s\n' "${regions[@]}" | shuf -n 1
}
parse_restart_containers() {
# CSV: "m3u-filter-vpn,m3u-editor,xtream-proxy" or JSON array.
# Falls back to GLUETUN_CONTAINER when unset.
parse_additional_restart_containers() {
# Sidecars to restart after gluetun. CSV or JSON array.
local raw="${RESTART_CONTAINERS:-}"
if [[ -z "$raw" ]]; then
echo "${GLUETUN_CONTAINER:-m3u-filter-vpn}"
return
fi
[[ -z "$raw" ]] && return 0
if [[ "$raw" =~ ^\[.*\]$ ]]; then
jq -r '.[]' <<<"$raw"
@@ -58,6 +54,23 @@ parse_restart_containers() {
tr ',' '\n' <<<"$raw" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' | awk 'NF'
}
parse_restart_containers() {
# Gluetun is always restarted first, then any RESTART_CONTAINERS (deduplicated).
local gluetun="${GLUETUN_CONTAINER:-m3u-filter-vpn}"
local -A seen=()
local container
echo "$gluetun"
seen["$gluetun"]=1
while IFS= read -r container; do
[[ -z "$container" ]] && continue
[[ -n "${seen[$container]+x}" ]] && continue
echo "$container"
seen["$container"]=1
done < <(parse_additional_restart_containers)
}
restart_containers() {
local container restarted=()
while IFS= read -r container; do