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
|
||||
# license: gpl-3
|
||||
|
||||
if [[ -z $(sudo systemctl status systemd-networkd | grep -e "dead") ]];then
|
||||
if [[ $(ls -l /etc/systemd/network | wc -l) != 0 ]];then
|
||||
echo "warning, there already are configs present"
|
||||
echo "do you want to continue? (Y/n)"
|
||||
read continue
|
||||
if [[ "$continue" == y ]] || [[ "$continue" == yes ]] || [[ -z "$continue" ]];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 "which networkmanager do you want to use?"
|
||||
echo "please enter the name or number of your choice"
|
||||
echo "1. systemd-resolved"
|
||||
read $c1
|
||||
if [[ "$c1" == "1" ]] || [[ "$c1" == "1." ]] || [[ "$c1" == "systemd-resolved" ]];then
|
||||
if [[ -z $(sudo systemctl status systemd-networkd | grep -e "dead") ]];then
|
||||
if [[ $(ls -l /etc/systemd/network | wc -l) != 0 ]];then
|
||||
echo "warning, there already are configs present"
|
||||
echo "do you want to continue? (Y/n)"
|
||||
read continue
|
||||
if [[ "$continue" == y ]] || [[ "$continue" == yes ]] || [[ -z "$continue" ]];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 "Please type out the Interfacename"
|
||||
echo "Please type out the IP-Adress you want to set (with CIDR)"
|
||||
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
|
||||
read ipstatic
|
||||
echo "Address=$ipstatic" >> "/etc/systemd/network/10-ethernet.network"
|
||||
echo "======================"
|
||||
echo "Please type out the MAC-Adress"
|
||||
echo "Please type out the Gateway 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
|
||||
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
|
||||
else
|
||||
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
|
||||
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
|
||||
else
|
||||
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
|
||||
echo "systemd-networkd is not running"
|
||||
exit
|
||||
fi
|
||||
else
|
||||
echo "systemd-networkd is not running"
|
||||
echo "selected manager not supported"
|
||||
exit
|
||||
fi
|
Loading…
Reference in New Issue
Block a user