config-get-netconf-eth0.sh 786 B

1234567891011
  1. #!/bin/bash -e
  2. # Update config.sh with the running IPv4 grml network configuration for eth0
  3. # Get predictiable alternative name as eth0 is not the default
  4. echo netDev=\"`ip -fam inet addr show dev eth0 | grep -m1 -o 'altname .*' | cut -d" " -f2`\" >> config.sh
  5. echo netAddress=\"`ip -fam inet addr show dev eth0 | grep -o 'inet .*' | cut -d" " -f2`\" >> config.sh
  6. echo netGateway=\"`ip -fam inet route show dev eth0 | grep -o 'default .*' | cut -d" " -f3`\" >> config.sh
  7. echo netBroadcast=\"`ip -fam inet addr show dev eth0 | grep -o 'inet .*' | cut -d" " -f2`\" >> config.sh
  8. echo netDNS1=\"`cat /etc/resolv.conf | grep -m1 -o 'nameserver .*' | cut -d" " -f2`\" >> config.sh
  9. echo netDNS2=\"`cat /etc/resolv.conf | grep -m2 -o 'nameserver .*' | tail -n1 | cut -d" " -f2`\" >> config.sh