31 lines
1.3 KiB
Bash
31 lines
1.3 KiB
Bash
#!/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
|
|
exit 0;
|
|
fi
|
|
if [[ -z "$(which netplan)" ]]; then
|
|
echo "Your system is not support netplan!"
|
|
echo "Please generate your network config!"
|
|
else
|
|
netplan_configs_count=`ls /etc/netplan/*.yaml|wc -l`
|
|
netplan_config_file=""
|
|
if [[ "$netplan_configs_count" == "0" ]]; then
|
|
netplan_config_file="/etc/netplan/00-installer-config.yaml"
|
|
sudo wget http://gitlab.tp.rulingcom.com/erictyl/install_r45_on_ubuntu_1804lts_doc/-/raw/master/default_netplan-config.yaml -O $netplan_config_file
|
|
else
|
|
netplan_config_file=`ls /etc/netplan/*.yaml|xargs|awk '{print $1}'`
|
|
fi
|
|
configure_netplan_py=`curl -sS 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 |