mirror of
https://github.com/elitak/nixos-infect.git
synced 2024-12-23 00:28:28 +03:00
don't use bash arrays for values
This commit is contained in:
parent
9c0a833bda
commit
e745ee3aa2
1 changed files with 8 additions and 8 deletions
16
nixos-infect
16
nixos-infect
|
@ -39,17 +39,17 @@ EOF
|
||||||
# XXX It'd be better if we used procfs for all this...
|
# XXX It'd be better if we used procfs for all this...
|
||||||
local IFS=$'\n'
|
local IFS=$'\n'
|
||||||
eth0_name=$(ip address show | grep '^2:' | awk -F': ' '{print $2}')
|
eth0_name=$(ip address show | grep '^2:' | 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_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 ' | sed -r 's|.*inet6 ([0-9a-f:]+)/([0-9]+).*|{ address="\1"; prefixLength=\2; }|' || ''))
|
eth0_ip6s=$(ip address show dev "$eth0_name" | grep 'inet6 ' | sed -r 's|.*inet6 ([0-9a-f:]+)/([0-9]+).*|{ address="\1"; prefixLength=\2; }|' || '')
|
||||||
gateway=($(ip route show dev "$eth0_name" | grep default | sed -r 's|default via ([0-9.]+).*|\1|'))
|
gateway=$(ip route show dev "$eth0_name" | grep default | sed -r 's|default via ([0-9.]+).*|\1|')
|
||||||
ether0=($(ip address show dev "$eth0_name" | grep link/ether | sed -r 's|.*link/ether ([0-9a-f:]+) .*|\1|'))
|
ether0=$(ip address show dev "$eth0_name" | grep link/ether | sed -r 's|.*link/ether ([0-9a-f:]+) .*|\1|')
|
||||||
|
|
||||||
eth1_name=$(ip address show | grep '^3:' | awk -F': ' '{print $2}')||true
|
eth1_name=$(ip address show | grep '^3:' | awk -F': ' '{print $2}')||true
|
||||||
if [ -n "$eth1_name" ];then
|
if [ -n "$eth1_name" ];then
|
||||||
eth1_ip4s=($(ip address show dev "$eth1_name" | grep 'inet ' | sed -r 's|.*inet ([0-9.]+)/([0-9]+).*|{ address="\1"; prefixLength=\2; }|'))
|
eth1_ip4s=$(ip address show dev "$eth1_name" | grep 'inet ' | sed -r 's|.*inet ([0-9.]+)/([0-9]+).*|{ address="\1"; prefixLength=\2; }|')
|
||||||
eth1_ip6s=($(ip address show dev "$eth1_name" | grep 'inet6 ' | sed -r 's|.*inet6 ([0-9a-f:]+)/([0-9]+).*|{ address="\1"; prefixLength=\2; }|' || ''))
|
eth1_ip6s=$(ip address show dev "$eth1_name" | grep 'inet6 ' | sed -r 's|.*inet6 ([0-9a-f:]+)/([0-9]+).*|{ address="\1"; prefixLength=\2; }|' || '')
|
||||||
ether1=($(ip address show dev "$eth1_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|')
|
||||||
gateway6=($(ip -6 route show dev "$eth1_name" | grep default | sed -r 's|default via ([0-9a-f:]+).*|\1|' || true))
|
gateway6=$(ip -6 route show dev "$eth1_name" | grep default | sed -r 's|default via ([0-9a-f:]+).*|\1|' || true)
|
||||||
interfaces1=<< EOF
|
interfaces1=<< EOF
|
||||||
$eth1_name = {
|
$eth1_name = {
|
||||||
ip4 = [$(for a in "${eth1_ip4s[@]}"; do echo -n "
|
ip4 = [$(for a in "${eth1_ip4s[@]}"; do echo -n "
|
||||||
|
|
Loading…
Reference in a new issue