1
0
mirror of https://github.com/byReqz/netset.git synced 2024-11-22 12:51:15 +00:00

add selector

This commit is contained in:
Nils 2021-02-18 17:22:01 +01:00
parent 3554d2b93d
commit be403af671
Signed by: byreqz
GPG Key ID: 396A62D7D436749E

246
netset.sh Normal file → Executable file
View File

@ -1,120 +1,128 @@
#!/bin/bash #!/bin/bash
# license: gpl-3 # license: gpl-3
echo "which networkmanager do you want to use?"
if [[ -z $(sudo systemctl status systemd-networkd | grep -e "dead") ]];then echo "please enter the name or number of your choice"
if [[ $(ls -l /etc/systemd/network | wc -l) != 0 ]];then echo "1. systemd-resolved"
echo "warning, there already are configs present" read $c1
echo "do you want to continue? (Y/n)" if [[ "$c1" == "1" ]] || [[ "$c1" == "1." ]] || [[ "$c1" == "systemd-resolved" ]];then
read continue if [[ -z $(sudo systemctl status systemd-networkd | grep -e "dead") ]];then
if [[ "$continue" == y ]] || [[ "$continue" == yes ]] || [[ -z "$continue" ]];then if [[ $(ls -l /etc/systemd/network | wc -l) != 0 ]];then
touch "/etc/systemd/network/10-ethernet.network" echo "warning, there already are configs present"
echo "[Match]" >> "/etc/systemd/network/10-ethernet.network" echo "do you want to continue? (Y/n)"
echo "Do you want to configure by Interfacename or MAC? (ifn/MAC)" read continue
read choice1 if [[ "$continue" == y ]] || [[ "$continue" == yes ]] || [[ -z "$continue" ]];then
if [[ "$choice1" =~ "ifn" ]];then touch "/etc/systemd/network/10-ethernet.network"
echo "======================" echo "[Match]" >> "/etc/systemd/network/10-ethernet.network"
echo "Please type out the Interfacename" echo "Do you want to configure by Interfacename or MAC? (ifn/MAC)"
echo "======================" read choice1
ip link show if [[ "$choice1" =~ "ifn" ]];then
read interface echo "======================"
echo "Name=$interface" >> "/etc/systemd/network/10-ethernet.network" echo "Please type out the Interfacename"
echo "" >> "/etc/systemd/network/10-ethernet.network" echo "======================"
elif [[ "$choice1" =~ "mac" ]];then ip link show
echo "======================" read interface
echo "Please type out the MAC-Adress" echo "Name=$interface" >> "/etc/systemd/network/10-ethernet.network"
echo "======================" echo "" >> "/etc/systemd/network/10-ethernet.network"
read mac elif [[ "$choice1" =~ "mac" ]];then
echo "MACAdress=$mac" >> "/etc/systemd/network/10-ethernet.network" echo "======================"
echo "" >> "/etc/systemd/network/10-ethernet.network" echo "Please type out the MAC-Adress"
else echo "======================"
echo "no proper input provided" read mac
exit echo "MACAdress=$mac" >> "/etc/systemd/network/10-ethernet.network"
fi echo "" >> "/etc/systemd/network/10-ethernet.network"
echo "[Network]" >> "/etc/systemd/network/10-ethernet.network" else
echo "======================" echo "no proper input provided"
echo "Please type out the IP-Adress you want to set (with CIDR)" exit
echo "======================" fi
read ipstatic echo "[Network]" >> "/etc/systemd/network/10-ethernet.network"
echo "Address=$ipstatic" >> "/etc/systemd/network/10-ethernet.network" echo "======================"
echo "======================" echo "Please type out the IP-Adress you want to set (with CIDR)"
echo "Please type out the Gateway adress" echo "======================"
echo "======================" read ipstatic
read gateway echo "Address=$ipstatic" >> "/etc/systemd/network/10-ethernet.network"
echo "Gateway=$gateway" >> "/etc/systemd/network/10-ethernet.network" echo "======================"
echo "======================" echo "Please type out the Gateway adress"
echo "Please type out the main DNS address (blank for none)" echo "======================"
echo "======================" read gateway
read dns echo "Gateway=$gateway" >> "/etc/systemd/network/10-ethernet.network"
if [[ -z "$dns" ]];then echo "======================"
echo "======================" echo "Please type out the main DNS address (blank for none)"
echo "Interface has been configured" echo "======================"
echo "restart systemd-networkd to apply the profile" read dns
echo "======================" if [[ -z "$dns" ]];then
exit echo "======================"
fi echo "Interface has been configured"
echo "DNS=$dns" >> "/etc/systemd/network/10-ethernet.network" echo "restart systemd-networkd to apply the profile"
echo "======================" echo "======================"
echo "Interface has been configured" exit
echo "restart systemd-networkd to apply the profile" fi
echo "======================" echo "DNS=$dns" >> "/etc/systemd/network/10-ethernet.network"
exit echo "======================"
else echo "Interface has been configured"
exit echo "restart systemd-networkd to apply the profile"
fi echo "======================"
else exit
touch "/etc/systemd/network/10-ethernet.network" else
echo "[Match]" >> "/etc/systemd/network/10-ethernet.network" exit
echo "Do you want to configure by Interfacename or MAC? (ifn/MAC)" fi
read choice1 else
if [[ "$choice1" =~ "ifn" ]];then touch "/etc/systemd/network/10-ethernet.network"
echo "======================" echo "[Match]" >> "/etc/systemd/network/10-ethernet.network"
echo "Please type out the Interfacename" echo "Do you want to configure by Interfacename or MAC? (ifn/MAC)"
echo "======================" read choice1
ip link show if [[ "$choice1" =~ "ifn" ]];then
read interface echo "======================"
echo "Name=$interface" >> "/etc/systemd/network/10-ethernet.network" echo "Please type out the Interfacename"
echo "" >> "/etc/systemd/network/10-ethernet.network" echo "======================"
elif [[ "$choice1" =~ "mac" ]];then ip link show
echo "======================" read interface
echo "Please type out the MAC-Adress" echo "Name=$interface" >> "/etc/systemd/network/10-ethernet.network"
echo "======================" echo "" >> "/etc/systemd/network/10-ethernet.network"
read mac elif [[ "$choice1" =~ "mac" ]];then
echo "MACAdress=$mac" >> "/etc/systemd/network/10-ethernet.network" echo "======================"
echo "" >> "/etc/systemd/network/10-ethernet.network" echo "Please type out the MAC-Adress"
else echo "======================"
echo "no proper input provided" read mac
exit echo "MACAdress=$mac" >> "/etc/systemd/network/10-ethernet.network"
fi echo "" >> "/etc/systemd/network/10-ethernet.network"
echo "[Network]" >> "/etc/systemd/network/10-ethernet.network" else
echo "======================" echo "no proper input provided"
echo "Please type out the IP-Adress you want to set (with CIDR)" exit
echo "======================" fi
read ipstatic echo "[Network]" >> "/etc/systemd/network/10-ethernet.network"
echo "Address=$ipstatic" >> "/etc/systemd/network/10-ethernet.network" echo "======================"
echo "======================" echo "Please type out the IP-Adress you want to set (with CIDR)"
echo "Please type out the Gateway adress" echo "======================"
echo "======================" read ipstatic
read gateway echo "Address=$ipstatic" >> "/etc/systemd/network/10-ethernet.network"
echo "Gateway=$gateway" >> "/etc/systemd/network/10-ethernet.network" echo "======================"
echo "======================" echo "Please type out the Gateway adress"
echo "Please type out the main DNS address (blank for none)" echo "======================"
echo "======================" read gateway
read dns echo "Gateway=$gateway" >> "/etc/systemd/network/10-ethernet.network"
if [[ -z "$dns" ]];then echo "======================"
echo "======================" echo "Please type out the main DNS address (blank for none)"
echo "Interface has been configured" echo "======================"
echo "restart systemd-networkd to apply the profile" read dns
echo "======================" if [[ -z "$dns" ]];then
exit echo "======================"
fi echo "Interface has been configured"
echo "DNS=$dns" >> "/etc/systemd/network/10-ethernet.network" echo "restart systemd-networkd to apply the profile"
echo "======================" echo "======================"
echo "Interface has been configured" exit
echo "restart systemd-networkd to apply the profile" fi
echo "======================" echo "DNS=$dns" >> "/etc/systemd/network/10-ethernet.network"
exit echo "======================"
fi echo "Interface has been configured"
else echo "restart systemd-networkd to apply the profile"
echo "systemd-networkd is not running" echo "======================"
exit exit
fi
else
echo "systemd-networkd is not running"
exit
fi
else
echo "selected manager not supported"
exit
fi fi