allow missing ip6 info

This commit is contained in:
Eric Litak 2017-02-14 00:37:47 -08:00
parent 0b48e18a3a
commit c0b008b0ee

View file

@ -77,15 +77,18 @@ EOF
}
EOF
# XXX It'd be better if we used procfs for all this...
local IFS=$'\n'
eth0_ip4s=($(ip address show dev eth0 | grep 'inet ' | sed -r 's|.*inet ([0-9.]+)/([0-9]+).*|{ address="\1"; prefixLength=\2; }|'))
eth0_ip6s=($(ip address show dev eth0 | grep 'inet6 .*global' | sed -r 's|.*inet6 ([0-9a-f:]+)/([0-9]+).*|{ address="\1"; prefixLength=\2; }|'))
eth1_ip4s=($(ip address show dev eth1 | grep 'inet ' | sed -r 's|.*inet ([0-9.]+)/([0-9]+).*|{ address="\1"; prefixLength=\2; }|'))
eth1_ip6s=($(ip address show dev eth1 | grep 'inet6 .*global' | sed -r 's|.*inet6 ([0-9a-f:]+)/([0-9]+).*|{ address="\1"; prefixLength=\2; }|'))
gateway=($(ip route show dev eth0 | grep default | sed -r 's|default via ([0-9.]+).*|\1|'))
gateway6=($(ip -6 route show dev eth0 | grep default | sed -r 's|default via ([0-9a-f:]+).*|\1|'))
ether0=($(ip address show dev eth0 | grep link/ether | sed -r 's|.*link/ether ([0-9a-f:]+) .*|\1|'))
ether1=($(ip address show dev eth1 | grep link/ether | sed -r 's|.*link/ether ([0-9a-f:]+) .*|\1|'))
eth0_name=$(ip address show | grep ^2: | awk -F': ' '{print $2}')
eth1_name=$(ip address show | grep ^3: | awk -F': ' '{print $2}')
eth0_ip4s=($(ip address show dev $eth0_name | grep 'inet ' | sed -r 's|.*inet ([0-9.]+)/([0-9]+).*|{ address="\1"; prefixLength=\2; }|'))
eth0_ip6s=($(ip address show dev $eth0_name | grep 'inet6 .*global' | sed -r 's|.*inet6 ([0-9a-f:]+)/([0-9]+).*|{ address="\1"; prefixLength=\2; }|' || true))
eth1_ip4s=($(ip address show dev $eth1_name | grep 'inet ' | sed -r 's|.*inet ([0-9.]+)/([0-9]+).*|{ address="\1"; prefixLength=\2; }|' || true))
eth1_ip6s=($(ip address show dev $eth1_name | grep 'inet6 .*global' | sed -r 's|.*inet6 ([0-9a-f:]+)/([0-9]+).*|{ address="\1"; prefixLength=\2; }|' || true))
gateway=($(ip route show dev $eth0_name | grep default | sed -r 's|default via ([0-9.]+).*|\1|'))
gateway6=($(ip -6 route show dev $eth0_name | grep default | sed -r 's|default via ([0-9a-f:]+).*|\1|' || true))
ether0=($(ip address show dev $eth0_name | grep link/ether | sed -r 's|.*link/ether ([0-9a-f:]+) .*|\1|'))
ether1=($(ip address show dev $eth1_name | grep link/ether | sed -r 's|.*link/ether ([0-9a-f:]+) .*|\1|'))
nameservers=($(grep ^nameserver /etc/resolv.conf | cut -f2 -d' '))
cat > /etc/nixos/networking.nix << EOF
@ -201,7 +204,10 @@ checkEnv() {
( req bzcat || echo "ERROR: Missing bzcat" ) && \
( req perl || echo "ERROR: Missing perl" ) && \
( req groupadd || echo "ERROR: Missing groupadd" ) && \
( req useradd || echo "ERROR: Missing useradd" ) \
( req useradd || echo "ERROR: Missing useradd" ) && \
( req ip || echo "ERROR: Missing ip" ) && \
( req awk || echo "ERROR: Missing awk" ) && \
( req cut || echo "ERROR: Missing cut" ) \
|| return 1
}