Network connection using nmcli via script

Edit: rpm and deb packages.

nmcli-manager-rpm-and-deb-packages.zip

For Rocky Linux, Fedora, etc version where NetworkManager is requred instead of networkmanager.

nmcli-manager-NM.zip

If using NetworkManager, the connection can manage via command line or use script(s). Packages yad, networkmanager and xterm mus be installed.

Connection scripts:

nm-connection-scripts.zip

Connect:

#!/bin/bash
## RJP 6.5.2024 Very simple NetworkManager connecting script
#
#
STATUS=$(nmcli dev status > /tmp/nm-status)
yad --center --width=400 --height=100 --text-align=center --button=OK:1 --title="Connect" --text="Connect Network using NetworkManager (nmcli) "

choose=$(cat /tmp/nm-status | \
yad --list --text="Choose device for network connection" --title="nm-connector" --height=500 --width=600 --center \
--column="Network Status $STATUS")
--button=Exit:1

cat "$choose" 2> /tmp/valinta.txt
cat /tmp/valinta.txt | awk '{print $2}' > /tmp/valinta2
cat /tmp/valinta2 | sed 's/^.//' > /tmp/valinta3

xterm -hold -e "nmcli device connect $(cat /tmp/valinta3) --ask"

Disconnect:

#!/bin/bash
## RJP 6.5.2024 Very simple NetworkManager disconnecting script
#
#
STATUS=$(nmcli dev status > /tmp/nm-status)
yad --center --width=400 --height=100 --button=OK:1 --title="Disconnect" --text-align=center --text="Disconnect Network using NetworkManager (nmcli) "
choose=$(cat /tmp/nm-status | \
yad --list --text="Choose device for disconnectin" --title="nm-connector" --height=500 --width=600 --center \
--column="Network Status $STATUS")
--button=Exit:1

cat "$choose" 2> /tmp/valinta.txt
cat /tmp/valinta.txt | awk '{print $2}' > /tmp/valinta2
cat /tmp/valinta2 | sed 's/^.//' > /tmp/valinta3

xterm -hold -e "nmcli device down $(cat /tmp/valinta3) "