More fixes and generalizing, add hypervisor WIP template

This commit is contained in:
Alex D. 2023-09-03 13:27:04 +00:00
parent 8bad04acb6
commit a80e93ec6e
Signed by: caskd
GPG Key ID: F92BA85F61F4C173
2 changed files with 38 additions and 5 deletions

34
hypervisor.sh Executable file
View File

@ -0,0 +1,34 @@
#!/bin/sh
. "$(dirname -- "$0")/netdev.sh"
# Physical
new_if_phys "phys0"
new_if_phys "phys1"
new_if_phys "phys2"
new_if_phys "phys3"
new_if_phys "phys4"
new_if_phys "phys5"
# Bridges
IFACE="br-v6"
new_if_bridge "$IFACE"
bridge_property 'stp_state' "$IFACE"
bridge_property 'mcast_router' "$IFACE"
bridge_property 'mcast_snooping' "$IFACE" '0' '' # TODO: Remove such entries when bridges play well with multicasting
bridge_property 'mcast_querier' "$IFACE"
bridge_property 'mcast_mld_version' "$IFACE" '2' ''
IFACE="br0"
new_if_bridge "$IFACE"
bridge_property 'stp_state' "$IFACE"
bridge_property 'mcast_router' "$IFACE"
bridge_property 'mcast_snooping' "$IFACE" '0' '' # TODO: Remove such entries when bridges play well with multicasting
bridge_property 'mcast_querier' "$IFACE"
bridge_property 'mcast_mld_version' "$IFACE" '2' ''
# Wireguard
IFACE="wg-tunnel"
new_if_wg "$IFACE"
addr_static_if "$IFACE" "172.22.12.5/32"
addr_static_if "$IFACE" "fd42:42:42::2:5/128"

View File

@ -2,7 +2,7 @@
# #
# Generate s6 network definitions # Generate s6 network definitions
# set -x set -x
header_eb() { header_eb() {
echo '#!/bin/execlineb -P' echo '#!/bin/execlineb -P'
@ -46,7 +46,7 @@ addrfam() {
# Use ipv6 if cannot autodetect of if no semicolons are present # Use ipv6 if cannot autodetect of if no semicolons are present
local addr="$1" local addr="$1"
local fam='6' local fam='6'
if which grep >/dev/null 2>&1 && echo "$addr" | grep -v ':'; then if which grep >/dev/null 2>&1 && echo "$addr" | grep -v ':' >/dev/null 2>&1; then
local fam='4' local fam='4'
fi fi
echo "$fam" echo "$fam"
@ -278,14 +278,13 @@ wgconf() {
header_path header_path
header_if "$if" header_if "$if"
cat <<EOF cat <<EOF
s6-envdir -i /etc/s6/env/interface.\${INTERFACE}.wg-config s6-envdir -I /etc/s6/env/interface.\${INTERFACE}.wg-config
importas -i CONFIG CONFIG importas -D /etc/wireguard/\${INTERFACE} CONFIG CONFIG
EOF EOF
echo 'wg setconf $INTERFACE $CONFIG' echo 'wg setconf $INTERFACE $CONFIG'
) rc/"$sname"/up ) rc/"$sname"/up
install -Dm644 <(echo oneshot) rc/"$sname"/type install -Dm644 <(echo oneshot) rc/"$sname"/type
install -Dm644 /dev/null rc/"$sname"/dependencies.d/interface."$if".create install -Dm644 /dev/null rc/"$sname"/dependencies.d/interface."$if".create
install -Dm644 <(echo "/etc/wireguard/$if") env/"$sname"/CONFIG
} }
new_if_vrf() { new_if_vrf() {