mirror of
https://github.com/byReqz/netset.git
synced 2024-11-22 12:51:15 +00:00
add selector
This commit is contained in:
parent
3554d2b93d
commit
be403af671
210
netset.sh
Normal file → Executable file
210
netset.sh
Normal file → Executable 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 "[Match]" >> "/etc/systemd/network/10-ethernet.network"
|
||||||
|
echo "Do you want to configure by Interfacename or MAC? (ifn/MAC)"
|
||||||
|
read choice1
|
||||||
|
if [[ "$choice1" =~ "ifn" ]];then
|
||||||
|
echo "======================"
|
||||||
|
echo "Please type out the Interfacename"
|
||||||
|
echo "======================"
|
||||||
|
ip link show
|
||||||
|
read interface
|
||||||
|
echo "Name=$interface" >> "/etc/systemd/network/10-ethernet.network"
|
||||||
|
echo "" >> "/etc/systemd/network/10-ethernet.network"
|
||||||
|
elif [[ "$choice1" =~ "mac" ]];then
|
||||||
|
echo "======================"
|
||||||
|
echo "Please type out the MAC-Adress"
|
||||||
|
echo "======================"
|
||||||
|
read mac
|
||||||
|
echo "MACAdress=$mac" >> "/etc/systemd/network/10-ethernet.network"
|
||||||
|
echo "" >> "/etc/systemd/network/10-ethernet.network"
|
||||||
|
else
|
||||||
|
echo "no proper input provided"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
echo "[Network]" >> "/etc/systemd/network/10-ethernet.network"
|
||||||
echo "======================"
|
echo "======================"
|
||||||
echo "Please type out the Interfacename"
|
echo "Please type out the IP-Adress you want to set (with CIDR)"
|
||||||
echo "======================"
|
echo "======================"
|
||||||
ip link show
|
read ipstatic
|
||||||
read interface
|
echo "Address=$ipstatic" >> "/etc/systemd/network/10-ethernet.network"
|
||||||
echo "Name=$interface" >> "/etc/systemd/network/10-ethernet.network"
|
|
||||||
echo "" >> "/etc/systemd/network/10-ethernet.network"
|
|
||||||
elif [[ "$choice1" =~ "mac" ]];then
|
|
||||||
echo "======================"
|
echo "======================"
|
||||||
echo "Please type out the MAC-Adress"
|
echo "Please type out the Gateway adress"
|
||||||
echo "======================"
|
echo "======================"
|
||||||
read mac
|
read gateway
|
||||||
echo "MACAdress=$mac" >> "/etc/systemd/network/10-ethernet.network"
|
echo "Gateway=$gateway" >> "/etc/systemd/network/10-ethernet.network"
|
||||||
echo "" >> "/etc/systemd/network/10-ethernet.network"
|
echo "======================"
|
||||||
else
|
echo "Please type out the main DNS address (blank for none)"
|
||||||
echo "no proper input provided"
|
echo "======================"
|
||||||
exit
|
read dns
|
||||||
fi
|
if [[ -z "$dns" ]];then
|
||||||
echo "[Network]" >> "/etc/systemd/network/10-ethernet.network"
|
echo "======================"
|
||||||
echo "======================"
|
echo "Interface has been configured"
|
||||||
echo "Please type out the IP-Adress you want to set (with CIDR)"
|
echo "restart systemd-networkd to apply the profile"
|
||||||
echo "======================"
|
echo "======================"
|
||||||
read ipstatic
|
exit
|
||||||
echo "Address=$ipstatic" >> "/etc/systemd/network/10-ethernet.network"
|
fi
|
||||||
echo "======================"
|
echo "DNS=$dns" >> "/etc/systemd/network/10-ethernet.network"
|
||||||
echo "Please type out the Gateway adress"
|
|
||||||
echo "======================"
|
|
||||||
read gateway
|
|
||||||
echo "Gateway=$gateway" >> "/etc/systemd/network/10-ethernet.network"
|
|
||||||
echo "======================"
|
|
||||||
echo "Please type out the main DNS address (blank for none)"
|
|
||||||
echo "======================"
|
|
||||||
read dns
|
|
||||||
if [[ -z "$dns" ]];then
|
|
||||||
echo "======================"
|
echo "======================"
|
||||||
echo "Interface has been configured"
|
echo "Interface has been configured"
|
||||||
echo "restart systemd-networkd to apply the profile"
|
echo "restart systemd-networkd to apply the profile"
|
||||||
echo "======================"
|
echo "======================"
|
||||||
exit
|
exit
|
||||||
|
else
|
||||||
|
exit
|
||||||
fi
|
fi
|
||||||
echo "DNS=$dns" >> "/etc/systemd/network/10-ethernet.network"
|
|
||||||
echo "======================"
|
|
||||||
echo "Interface has been configured"
|
|
||||||
echo "restart systemd-networkd to apply the profile"
|
|
||||||
echo "======================"
|
|
||||||
exit
|
|
||||||
else
|
else
|
||||||
exit
|
touch "/etc/systemd/network/10-ethernet.network"
|
||||||
|
echo "[Match]" >> "/etc/systemd/network/10-ethernet.network"
|
||||||
|
echo "Do you want to configure by Interfacename or MAC? (ifn/MAC)"
|
||||||
|
read choice1
|
||||||
|
if [[ "$choice1" =~ "ifn" ]];then
|
||||||
|
echo "======================"
|
||||||
|
echo "Please type out the Interfacename"
|
||||||
|
echo "======================"
|
||||||
|
ip link show
|
||||||
|
read interface
|
||||||
|
echo "Name=$interface" >> "/etc/systemd/network/10-ethernet.network"
|
||||||
|
echo "" >> "/etc/systemd/network/10-ethernet.network"
|
||||||
|
elif [[ "$choice1" =~ "mac" ]];then
|
||||||
|
echo "======================"
|
||||||
|
echo "Please type out the MAC-Adress"
|
||||||
|
echo "======================"
|
||||||
|
read mac
|
||||||
|
echo "MACAdress=$mac" >> "/etc/systemd/network/10-ethernet.network"
|
||||||
|
echo "" >> "/etc/systemd/network/10-ethernet.network"
|
||||||
|
else
|
||||||
|
echo "no proper input provided"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
echo "[Network]" >> "/etc/systemd/network/10-ethernet.network"
|
||||||
|
echo "======================"
|
||||||
|
echo "Please type out the IP-Adress you want to set (with CIDR)"
|
||||||
|
echo "======================"
|
||||||
|
read ipstatic
|
||||||
|
echo "Address=$ipstatic" >> "/etc/systemd/network/10-ethernet.network"
|
||||||
|
echo "======================"
|
||||||
|
echo "Please type out the Gateway adress"
|
||||||
|
echo "======================"
|
||||||
|
read gateway
|
||||||
|
echo "Gateway=$gateway" >> "/etc/systemd/network/10-ethernet.network"
|
||||||
|
echo "======================"
|
||||||
|
echo "Please type out the main DNS address (blank for none)"
|
||||||
|
echo "======================"
|
||||||
|
read dns
|
||||||
|
if [[ -z "$dns" ]];then
|
||||||
|
echo "======================"
|
||||||
|
echo "Interface has been configured"
|
||||||
|
echo "restart systemd-networkd to apply the profile"
|
||||||
|
echo "======================"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
echo "DNS=$dns" >> "/etc/systemd/network/10-ethernet.network"
|
||||||
|
echo "======================"
|
||||||
|
echo "Interface has been configured"
|
||||||
|
echo "restart systemd-networkd to apply the profile"
|
||||||
|
echo "======================"
|
||||||
|
exit
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
touch "/etc/systemd/network/10-ethernet.network"
|
echo "systemd-networkd is not running"
|
||||||
echo "[Match]" >> "/etc/systemd/network/10-ethernet.network"
|
exit
|
||||||
echo "Do you want to configure by Interfacename or MAC? (ifn/MAC)"
|
|
||||||
read choice1
|
|
||||||
if [[ "$choice1" =~ "ifn" ]];then
|
|
||||||
echo "======================"
|
|
||||||
echo "Please type out the Interfacename"
|
|
||||||
echo "======================"
|
|
||||||
ip link show
|
|
||||||
read interface
|
|
||||||
echo "Name=$interface" >> "/etc/systemd/network/10-ethernet.network"
|
|
||||||
echo "" >> "/etc/systemd/network/10-ethernet.network"
|
|
||||||
elif [[ "$choice1" =~ "mac" ]];then
|
|
||||||
echo "======================"
|
|
||||||
echo "Please type out the MAC-Adress"
|
|
||||||
echo "======================"
|
|
||||||
read mac
|
|
||||||
echo "MACAdress=$mac" >> "/etc/systemd/network/10-ethernet.network"
|
|
||||||
echo "" >> "/etc/systemd/network/10-ethernet.network"
|
|
||||||
else
|
|
||||||
echo "no proper input provided"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
echo "[Network]" >> "/etc/systemd/network/10-ethernet.network"
|
|
||||||
echo "======================"
|
|
||||||
echo "Please type out the IP-Adress you want to set (with CIDR)"
|
|
||||||
echo "======================"
|
|
||||||
read ipstatic
|
|
||||||
echo "Address=$ipstatic" >> "/etc/systemd/network/10-ethernet.network"
|
|
||||||
echo "======================"
|
|
||||||
echo "Please type out the Gateway adress"
|
|
||||||
echo "======================"
|
|
||||||
read gateway
|
|
||||||
echo "Gateway=$gateway" >> "/etc/systemd/network/10-ethernet.network"
|
|
||||||
echo "======================"
|
|
||||||
echo "Please type out the main DNS address (blank for none)"
|
|
||||||
echo "======================"
|
|
||||||
read dns
|
|
||||||
if [[ -z "$dns" ]];then
|
|
||||||
echo "======================"
|
|
||||||
echo "Interface has been configured"
|
|
||||||
echo "restart systemd-networkd to apply the profile"
|
|
||||||
echo "======================"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
echo "DNS=$dns" >> "/etc/systemd/network/10-ethernet.network"
|
|
||||||
echo "======================"
|
|
||||||
echo "Interface has been configured"
|
|
||||||
echo "restart systemd-networkd to apply the profile"
|
|
||||||
echo "======================"
|
|
||||||
exit
|
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "systemd-networkd is not running"
|
echo "selected manager not supported"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
Loading…
Reference in New Issue
Block a user