From 956c2a82620feb128238536bcba9bc6cd7e1ca85 Mon Sep 17 00:00:00 2001 From: bohung Date: Wed, 31 Aug 2022 20:08:44 +0800 Subject: [PATCH] Fix bug. --- configure_netplan.sh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/configure_netplan.sh b/configure_netplan.sh index 53a1dc4..df8fc90 100644 --- a/configure_netplan.sh +++ b/configure_netplan.sh @@ -1,4 +1,15 @@ #!/usr/bin/bash +if [[ "$1" == "--status" ]]; then + default_route=`ip -o -4 route show to default` + if [[ -z "$default_route" ]]; then + echo "No default network interface detected!" + else + interface=`echo $default_route|awk '{print $5}'|xargs|awk '{print $1}'` + ipv4=`echo $default_route|awk '{print $9}'|xargs|awk '{print $1}'` + echo "network interface: $interface" + echo "IPv4: $ipv4" + fi +fi if [[ -z "$(which netplan)" ]]; then echo "Your system is not support netplan!" echo "Please generate your network config!" @@ -11,6 +22,9 @@ else else netplan_config_file=`ls /etc/netplan/*.yaml|xargs|awk '{print $1}'` fi - wget http://gitlab.tp.rulingcom.com/erictyl/install_r45_on_ubuntu_1804lts_doc/-/raw/master/configure_netplan.py -O configure_netplan.py + configure_netplan_py=`curl http://gitlab.tp.rulingcom.com/erictyl/install_r45_on_ubuntu_1804lts_doc/-/raw/master/configure_netplan.py` + if [[ ! -z "$configure_netplan_py" ]]; then + echo "$configure_netplan_py" > configure_netplan.py + fi sudo python3 configure_netplan.py "$netplan_config_file" fi \ No newline at end of file