diff options
| author | Jan Tuomi <jan@jantuomi.fi> | 2026-08-05 13:53:07 +0300 |
|---|---|---|
| committer | Jan Tuomi <jan@jantuomi.fi> | 2026-08-05 14:38:00 +0300 |
| commit | 469afb98140c2a33ecd0124381035423a2006e1e (patch) | |
| tree | c3e234437df915d47831829d3e34671b82be8ef2 /roles/jail/templates/usr_local_bin_jail_net.j2 | |
| parent | d38fe54ab035f8e3248b8e20a58abd89861833bf (diff) | |
Restructure jail ip references
Diffstat (limited to 'roles/jail/templates/usr_local_bin_jail_net.j2')
| -rw-r--r-- | roles/jail/templates/usr_local_bin_jail_net.j2 | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/roles/jail/templates/usr_local_bin_jail_net.j2 b/roles/jail/templates/usr_local_bin_jail_net.j2 index e9873a3..e8ce462 100644 --- a/roles/jail/templates/usr_local_bin_jail_net.j2 +++ b/roles/jail/templates/usr_local_bin_jail_net.j2 @@ -1,27 +1,16 @@ #!/bin/sh # jail_net - manage jail LAN networking lifecycle -# Usage: jail_net <prestart|poststart|prestop|poststop> <jail_num> <jail_name> +# Usage: jail_net <prestart|poststart|prestop|poststop> <jail_name> <jail_num> <jail_ip_cidr> set -e STAGE="$1" -NUM="$2" -NAME="$3" +NAME="$2" +NUM="$3" +IP="$4" BRIDGE="brlan0" -LAN_BASE="{{ jail_lan_cidr | ipv4_host }}" -LAN_PREFIX="{{ jail_lan_cidr | ipv4_prefixlen }}" -LAN_OFFSET="{{ jail_lan_offset }}" -DEFAULT_ROUTE="{{ jail_lan_cidr | ipv4_nth(1 + jail_lan_offset | int) }}" - -# Compute jail IP from jail_num + offset -_nth=$(( LAN_OFFSET + NUM )) -_a=$(echo "$LAN_BASE" | cut -d. -f1) -_b=$(echo "$LAN_BASE" | cut -d. -f2) -_c=$(echo "$LAN_BASE" | cut -d. -f3) -_d=$(echo "$LAN_BASE" | cut -d. -f4) -_total=$(( (_a << 24) + (_b << 16) + (_c << 8) + _d + _nth )) -IP="$(( (_total >> 24) & 255 )).$(( (_total >> 16) & 255 )).$(( (_total >> 8) & 255 )).$(( _total & 255 ))/${LAN_PREFIX}" +DEFAULT_ROUTE="{{ jail_ips.ingress }}" # --- Cleanup functions --- @@ -121,7 +110,7 @@ case "$STAGE" in prestop) _prestop ;; poststop) _poststop ;; *) - echo "Usage: jail_net <prestart|poststart|prestop|poststop> <num> <name>" >&2 + echo "Usage: jail_net <prestart|poststart|prestop|poststop> <name> <num> <ip_cidr>" >&2 exit 1 ;; esac |
