mirror of
https://github.com/byReqz/netset.git
synced 2024-11-21 20:43:13 +00:00
reworked networkmanager
This commit is contained in:
parent
b307e38fbe
commit
45ede2e86a
92
netset.sh
92
netset.sh
@ -7,7 +7,7 @@ if [[ -n $(systemctl --version | grep -e "systemd") ]];then
|
|||||||
else
|
else
|
||||||
echo "1. systemd-resolved [not installed]"
|
echo "1. systemd-resolved [not installed]"
|
||||||
fi
|
fi
|
||||||
if [[ -n $(NetworkManager -h | grep -e "Usage:") ]];then
|
if [[ -n $(ls /etc | grep -e "NetworkManager") ]];then
|
||||||
echo "2. NetworkManager [installed]"
|
echo "2. NetworkManager [installed]"
|
||||||
else
|
else
|
||||||
echo "2. NetworkManager [not installed]"
|
echo "2. NetworkManager [not installed]"
|
||||||
@ -137,30 +137,82 @@ if [[ "$c1" == "1" ]] || [[ "$c1" == "1." ]] || [[ "$c1" == "systemd-resolved" ]
|
|||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
elif [[ "$c1" == "2" ]] || [[ "$c1" == "2." ]] || [[ "$c1" == "networkmanager" ]];then
|
elif [[ "$c1" == "2" ]] || [[ "$c1" == "2." ]] || [[ "$c1" == "networkmanager" ]];then
|
||||||
|
echo "======================"
|
||||||
echo "select a new connectionname"
|
echo "select a new connectionname"
|
||||||
|
echo "======================"
|
||||||
read nmc
|
read nmc
|
||||||
nmcli networking on
|
echo "======================"
|
||||||
nmcli connection add type ethernet con-name "$nmc"
|
echo "type the name of the interface to use"
|
||||||
nmcli connection modify "$nmc" connection.autoconnect yes
|
echo ""
|
||||||
nmcli connection modify "$nmc" connection.autoconnect-priority -999
|
ip a
|
||||||
nmcli connection modify "$nmc" connection.autoconnect-retries -1
|
echo "======================"
|
||||||
nmcli connection modify "$nmc" connection.read-only no
|
read nmcif
|
||||||
nmcli connection modify "$nmc" connection.autoconnect-slaves -1
|
echo "======================"
|
||||||
nmcli connection modify "$nmc" connection.wait-device-timeout -1
|
echo "input the ip to set (cidr notion also accepted, defaults to /24 if empty)"
|
||||||
echo "----------------------------"
|
echo "======================"
|
||||||
echo "input the ip to set (cidr notion also accepted)"
|
|
||||||
echo "----------------------------"
|
|
||||||
read nmcip
|
read nmcip
|
||||||
nmcli con mod "$nmc" ipv4.method manual ipv4.addr "$nmcip"
|
if [[ -z "$(echo $nmcip | grep -e "/")" ]];then
|
||||||
# sets hetzner dns
|
nmcip=""$nmcip"/24"
|
||||||
nmcli con modify "$nmc" +ipv4.dns 213.133.98.98
|
fi
|
||||||
echo "connection has been set (restart network manager if necessary)"
|
echo "======================"
|
||||||
|
echo "input the gateway adress to set"
|
||||||
|
echo "======================"
|
||||||
|
read nmcgw
|
||||||
|
echo "======================"
|
||||||
|
echo "input the dns server adress(es) to set"
|
||||||
|
echo "leave empty for default"
|
||||||
|
echo "======================"
|
||||||
|
read nmcdns
|
||||||
|
if [[ -z "$nmcdns" ]];then
|
||||||
|
# those are the default hetzner dns servers
|
||||||
|
nmcdns="213.133.98.98"
|
||||||
|
fi
|
||||||
|
echo -e "[connection]" > ."$nmc".nmconnection
|
||||||
|
echo -e "id="$nmc"" >> ."$nmc".nmconnection
|
||||||
|
echo -e "uuid=$(curl -s "http://uuid4.com/?count=1&format=raw")" >> ."$nmc".nmconnection
|
||||||
|
echo -e "type=ethernet" >> ."$nmc".nmconnection
|
||||||
|
echo -e "autoconnect-priority=1" >> ."$nmc".nmconnection
|
||||||
|
echo -e "interface-name="$nmcif"" >> ."$nmc".nmconnection
|
||||||
|
# not sure if this actually works
|
||||||
|
# echo -e "permissions=user:*:;" >> ."$nmc".nmconnection
|
||||||
|
echo -e "timestamp=$(date +%s)" >> ."$nmc".nmconnection
|
||||||
|
echo -e "" >> ."$nmc".nmconnection
|
||||||
|
echo -e "[ethernet]" >> ."$nmc".nmconnection
|
||||||
|
echo -e "auto-negotiate=true" >> ."$nmc".nmconnection
|
||||||
|
echo -e "mac-address-blacklist=" >> ."$nmc".nmconnection
|
||||||
|
echo -e "" >> ."$nmc".nmconnection
|
||||||
|
echo -e "[ipv4]" >> ."$nmc".nmconnection
|
||||||
|
echo -e "address1="$nmcip","$nmcgw"" >> ."$nmc".nmconnection
|
||||||
|
echo -e "dns="$nmcdns";" >> ."$nmc".nmconnection
|
||||||
|
echo -e "dns-search=" >> ."$nmc".nmconnection
|
||||||
|
echo -e "method=manual" >> ."$nmc".nmconnection
|
||||||
|
echo -e "" >> ."$nmc".nmconnection
|
||||||
|
echo -e "[ipv6]" >> ."$nmc".nmconnection
|
||||||
|
echo -e "addr-gen-mode=stable-privacy" >> ."$nmc".nmconnection
|
||||||
|
echo -e "dns-search=" >> ."$nmc".nmconnection
|
||||||
|
echo -e "method=auto" >> ."$nmc".nmconnection
|
||||||
|
echo -e "" >> ."$nmc".nmconnection
|
||||||
|
echo -e "[proxy]" >> ."$nmc".nmconnection
|
||||||
|
echo "======================"
|
||||||
|
echo "the connection file has been created in $PWD"
|
||||||
|
echo "should it be installed right now? (requires root) [y/N]"
|
||||||
|
echo "======================"
|
||||||
|
read nmcyn1
|
||||||
|
if [[ "$nmcyn1" == "y" ]] || [[ "$nmcyn1" == "Y" ]] || [[ "$nmcyn1" == "yes" ]];then
|
||||||
|
mv ."$nmc".nmconnection /etc/NetworkManager/system-connections/"$nmc".nmconnection
|
||||||
|
chown root:root /etc/NetworkManager/system-connections/"$nmc".nmconnection
|
||||||
|
chmod 600 /etc/NetworkManager/system-connections/"$nmc".nmconnection
|
||||||
|
systemctl restart NetworkManager
|
||||||
|
else
|
||||||
|
mv ."$nmc".nmconnection "$nmc".nmconnection
|
||||||
|
exit
|
||||||
|
fi
|
||||||
exit
|
exit
|
||||||
elif [[ "$c1" == "3" ]] || [[ "$c1" == "3." ]] || [[ "$c1" == "netplan" ]];then
|
elif [[ "$c1" == "3" ]] || [[ "$c1" == "3." ]] || [[ "$c1" == "netplan" ]];then
|
||||||
echo "please enter the interface name"
|
echo "please enter the interface name"
|
||||||
echo "----------------------------"
|
echo "======================"
|
||||||
ip l
|
ip l
|
||||||
echo "----------------------------"
|
echo "======================"
|
||||||
read npif
|
read npif
|
||||||
echo "network:" > $PWD/.netplan.yaml
|
echo "network:" > $PWD/.netplan.yaml
|
||||||
echo -e " version: 2" >> $PWD/.netplan.yaml
|
echo -e " version: 2" >> $PWD/.netplan.yaml
|
||||||
@ -184,10 +236,10 @@ elif [[ "$c1" == "3" ]] || [[ "$c1" == "3." ]] || [[ "$c1" == "netplan" ]];then
|
|||||||
else
|
else
|
||||||
echo -e " addresses: ["$npdns"]" >> $PWD/.netplan.yaml
|
echo -e " addresses: ["$npdns"]" >> $PWD/.netplan.yaml
|
||||||
fi
|
fi
|
||||||
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)"
|
||||||
echo "----------------------------"
|
echo "======================"
|
||||||
read $npyn2
|
read $npyn2
|
||||||
if [[ "$npyn2" == "y" ]] || [[ "$npyn2" == "Y" ]] || [[ "$npyn2" == "yes" ]];then
|
if [[ "$npyn2" == "y" ]] || [[ "$npyn2" == "Y" ]] || [[ "$npyn2" == "yes" ]];then
|
||||||
mv .netplan.yaml /etc/netplan/netplan.yaml
|
mv .netplan.yaml /etc/netplan/netplan.yaml
|
||||||
|
Loading…
Reference in New Issue
Block a user