From c082115abb2fb178151f3be195ac4ba82afd6424 Mon Sep 17 00:00:00 2001 From: Nils Date: Mon, 22 Feb 2021 13:39:44 +0100 Subject: [PATCH] improved netplan config --- README.md | 8 ++++++++ netset.sh | 42 +++++++++++++++++++++++++++++------------- 2 files changed, 37 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index bdcf6cc..14969f6 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,10 @@ # netset quick and dirty network interface generator + +### features: +- ethernet config generation +- currently supports networkmanager, systemd-networkd and netplan + +# usage +just run the script, there are currently no options + diff --git a/netset.sh b/netset.sh index 36fe9bc..5a7887f 100755 --- a/netset.sh +++ b/netset.sh @@ -214,28 +214,44 @@ elif [[ "$c1" == "3" ]] || [[ "$c1" == "3." ]] || [[ "$c1" == "netplan" ]];then ip l echo "======================" read npif - echo "network:" > $PWD/.netplan.yaml - echo -e " version: 2" >> $PWD/.netplan.yaml - echo -e " renderer: networkd" >> $PWD/.netplan.yaml - echo -e " ethernets:" >> $PWD/.netplan.yaml - echo -e " $npif:" >> $PWD/.netplan.yaml - echo -e " addresses:" >> $PWD/.netplan.yaml if [[ -n $(ip a | grep -e "$npif") ]];then + echo "======================" + echo "select the renderer to use, defaults to networkd" + if [[ -n $(ls /etc | grep -e "NetworkManager") ]];then + echo "- Networkmanager [nm]" + fi + if [[ -n $(systemctl --version | grep -e "systemd") ]];then + echo "- systemd-networkd [nd]" + fi + echo "======================" + read nprd + if [[ "$nprd" == "nm" ]] || [[ "$nprd" == "networkmanager" ]] || [[ "$nprd" == "NetworkManager" ]];then + nprd="NetworkManager" + elif [[ "$nprd" == "nd" ]] || [[ "$nprd" == "networkd" ]] || [[ "$nprd" == "systemd-networkd" ]];then + nprd="networkd" + else + nprd="networkd" + fi echo "please enter the ip adress to set (with cidr notation)" read npip - echo -e " - "$npip"" >> $PWD/.netplan.yaml echo "please enter the gateway adress to set" read npgw - echo -e " gateway4: "$npgw"" >> $PWD/.netplan.yaml - echo -e " nameservers:" >> $PWD/.netplan.yaml - echo -e " search: [mydomain, otherdomain]" >> $PWD/.netplan.yaml echo "please enter the dns servers adress, leave empty for default" read npdns if [[ -z "$npdns" ]];then - echo -e " addresses: [213.133.98.98]" >> $PWD/.netplan.yaml - else - echo -e " addresses: ["$npdns"]" >> $PWD/.netplan.yaml + npdns="213.133.98.98" fi + echo "network:" > $PWD/.netplan.yaml + echo -e " version: 2" >> $PWD/.netplan.yaml + echo -e " renderer: "$nprd"" >> $PWD/.netplan.yaml + echo -e " ethernets:" >> $PWD/.netplan.yaml + echo -e " "$npif":" >> $PWD/.netplan.yaml + echo -e " addresses:" >> $PWD/.netplan.yaml + echo -e " - "$npip"" >> $PWD/.netplan.yaml + echo -e " gateway4: "$npgw"" >> $PWD/.netplan.yaml + echo -e " nameservers:" >> $PWD/.netplan.yaml + echo -e " search: [mydomain, otherdomain]" >> $PWD/.netplan.yaml + echo -e " addresses: ["$npdns"]" >> $PWD/.netplan.yaml echo "======================" echo "config has been generated in the current directory" echo "should the config be installed now? (y/N)"