scriptbox/alpine-initramfs-ipv6/alpine-initramfs-ipv6.patch

83 lines
2.2 KiB
Diff

271a272,350
> # configure ipv6 on initramfs
> # Valid syntaxes:
> # ip6=client-ip/gateway-ip/interface/dns1/dns2
> #
> configure_ip6() {
> [ -n "$MAC_ADDRESS" ] && return
>
> $MOCK modprobe -a ipv6
>
> local IFS='/'
> # shellcheck disable=SC2086
> set -- ${KOPT_ip6}
> unset IFS
>
> local client6_ip="$1"
> local gw6_ip="$2"
> local iface="$3"
> local dns1="$4"
> local dns2="$5"
>
> if [ -e "$ROOT"/etc/mactab ]; then
> $MOCK nameif -s
> fi
>
> if [ -z "$iface" ] && [ -n "$KOPT_BOOTIF" ]; then
> mac=$(printf "%s\n" "$KOPT_BOOTIF"|sed 's/^01-//;s/-/:/g')
> iface=$(grep -l "$mac" "$ROOT"/sys/class/net/*/address | awk -F/ '{print $(NF-1); exit}')
> fi
>
> # Bring interface up
> if [ -n "$iface" ]; then
> $MOCK ip link set dev "$iface" up
> sleep 3 # wait for interface to fully up.
> fi
>
> if [ -z "$iface" ]; then
> # shellcheck disable=SC2046
> set -- $(ethernets)
> for i in "$@"; do
> $MOCK ip link set dev "$i" up
> done
> iface=$(find_first_interface_up "$@") || iface="$1"
>
> # we will use the found interface later so lets keep it up
> for i in "$@"; do
> if [ "$i" != "$iface" ]; then
> $MOCK ip link set dev "$i" down
> fi
> done
> fi
>
> if [ -z "$iface" ]; then
> echo "ERROR: IP requested but no network interface was found"
> return 1
> fi
>
> if [ -z "$client6_ip" ] && [ -z "$netmask" ]; then
> return
> fi
> ebegin "Setting IP ($iface)"
>
> if ip -6 addr add $client6_ip dev $iface; then
> # this is definitely not required by all ipv6 implementation
> # but it's better to keep things working for all deployment possible
> #
> # metric is mandatory!
> [ -z "$gw6_ip" ] || ip -6 route add "$gw6_ip" dev $iface metric 256
> [ -z "$gw6_ip" ] || ip -6 route add ::0/0 via "$gw6_ip" dev "$iface" metric 128
> fi
> eend $?
>
> # Never executes if variables are empty
> for i in $dns1 $dns2; do
> echo "nameserver $i" >> /etc/resolv.conf
> done
>
> MAC_ADDRESS=$(cat "$ROOT/sys/class/net/$iface/address")
> }
>
513a593
> ip6