Help with script to enable/disable wifi based on connecting/disconnecting a network cable


Regarding the script to enable/disable wifi based on connecting/disconnecting a network cable, which can be found on igelexperts and the community github; what are thoughts on changing it from:

cat <<“EOF” > /etc/NetworkManager/dispatcher.d/99-wlan

#!/bin/bash

if [ “$1” = “eth0” -o “$1” = “eth1” ]; then

case “$2” in

up)

nmcli radio wifi off

;;

down)

nmcli radio wifi on

;;

esac

fi

EOF

chmod +x /etc/NetworkManager/dispatcher.d/99-wlan“`

to:

“`cat <<“EOF” > /etc/NetworkManager/dispatcher.d/99-wlan

#!/bin/bash

wired_interfaces=”en.|eth.”

if [[ “$1” =~ $wired_interfaces ]]; then

case “$2” in

up)

nmcli radio wifi off

;;

down)

nmcli radio wifi on

;;

esac

fi

EOF

chmod +x /etc/NetworkManager/dispatcher.d/99-wlan

I have tested it and it works for me. The benefit of the change is that it should cover any ethernet connection regardless of the interface name. I know eth0 and eth1 should cover most instances, but thinking this would help future proof it in case there is ever more than 2 options for ethernet connections on a device.


The first one was working prior to 11.04. Does the second one work with 11.04?


both work for me on 11.04

the one I am currently working/testing with is running 11.04.253


So, is this new version working just fine? If not, what are the issues?


yeah, both versions of the script work fine for me. I just came across the other version someone posted for ubuntu while researching another issue. So I thought I would ask what thoughts were about updating the github script to have the variable used instead of specifying the interfaces.

The issue I am researching is what I mentioned in this message: igelcommunity.slack.com/archives/C8GP9JHQE/p1610385883393200


Thinking… So could we have a script that runs on final network command that checks for a wired network connection and if not found, then start wifi?

Something like:

ethtool eth0 | grep ‘Link detected: no’


This is awesome! Great idea if we start doing more UD Pockets

Continue reading and comment on the thread ‘Help with script to enable/disable wifi based on connecting/disconnecting a network cable’.  Not a member? Join Here!

Learn more, search the IGEL Knowledge Base



Ask a question or comment on the above messasge thread?

Join or log in to the IGEL Community to ask us anything and meet other IGEL customers, partners, and EUC enthusiasts.

Submit a question, or Join Today!


Popular Message Threads


Categories & Tags: