1
0
mirror of https://github.com/byReqz/netset.git synced 2024-11-21 20:43:13 +00:00

improved netplan config

This commit is contained in:
Nils 2021-02-22 13:39:44 +01:00
parent 45ede2e86a
commit c082115abb
Signed by: byreqz
GPG Key ID: 396A62D7D436749E
2 changed files with 37 additions and 13 deletions

View File

@ -1,2 +1,10 @@
# netset # netset
quick and dirty network interface generator 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

View File

@ -214,28 +214,44 @@ elif [[ "$c1" == "3" ]] || [[ "$c1" == "3." ]] || [[ "$c1" == "netplan" ]];then
ip l ip l
echo "======================" echo "======================"
read npif 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 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)" echo "please enter the ip adress to set (with cidr notation)"
read npip read npip
echo -e " - "$npip"" >> $PWD/.netplan.yaml
echo "please enter the gateway adress to set" echo "please enter the gateway adress to set"
read npgw 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" echo "please enter the dns servers adress, leave empty for default"
read npdns read npdns
if [[ -z "$npdns" ]];then if [[ -z "$npdns" ]];then
echo -e " addresses: [213.133.98.98]" >> $PWD/.netplan.yaml npdns="213.133.98.98"
else
echo -e " addresses: ["$npdns"]" >> $PWD/.netplan.yaml
fi 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 "======================"
echo "config has been generated in the current directory" echo "config has been generated in the current directory"
echo "should the config be installed now? (y/N)" echo "should the config be installed now? (y/N)"