Forum › Forums › antiX-development › Development › [Testers needed] antiX wifi switcher (bash script)
- This topic has 24 replies, 8 voices, and was last updated Sep 17-12:55 pm by Xecure.
-
AuthorPosts
-
September 14, 2020 at 9:34 pm #41706Member
ex_Koo
::I checked this and think i download the right one. (antix-wifi-switch-019.zip) antiX-19 runit X64
To rule this out completely, @Koo, you did not perhaps download the wrong (first instead of second) zip-file ?
No problems with runit here, tested on a live-stick with persistence, 32 bit, base.
Just tried again and the same thing happens after I go from connman to ceni, I see this message below which puzzles me eth0? ,and I lose internet straight away even with out rebooting.
Plus the ceni network interface screen opens as if I need to reconfigure my wifi again ? I would have thought that ceni would already been configured the first time and stored my password as connman has done.?Go back to connman even without rebooting and wifi works straight up.
antix-wifi-switch Select the program to manage your Wi-Fi Switching to ceni Stoping Connman program and service [ ok ] Stopping Connection Manager:. Removing cmst from startup resolv.conf configuration: connman Replacing /etc/resolv.conf Restarting networking service [warn] Running /etc/init.d/networking restart is deprecated because it may not re-enable some [ ok ] Reconfiguring network interfaces... eth0 done. Stopping all wpa_supplicant processes Launching ceni urxvt -e sudo ceniI’m happy with connman working just not sure why ceni has gone wobbly.
@masinick
I don’t mix and match anymore as stable will do, I just install git versions of the latest if it not the repo and don’t mine the odd cargo either. lolSeptember 15, 2020 at 12:21 am #41708Memberex_Koo
::I’m not convinced about this now as my Ethernet is not working anymore. Ceni or connman but I will do a fresh base install in a few days.
September 15, 2020 at 2:16 am #41709Member
Xecure
::Sorry for the problems you are experiencing, Koo.
For the ceni problem, set it up and try after reboot to do:
sudo service networking status
to see if networking service is running properly
sudo service connman status
to see that connman has NOT automatically started on boot (it should say “[FAIL]”)
Try restarting the networking service and see if wifi autoconnects
sudo service networking restartIf it doesn’t autoconnect, see if changing the /etc/netwrok/interface from
allow-hotplug wlan0
to
auto wlan0
and rebooting has wifi autoconnect using the ceni configuration.I’m not convinced about this now as my Ethernet is not working anymore.
Does this happen for both connman and ceni? The script was specifically thought out for Wifi, so maybe I need to change it so that it also considers unblocking ethernet if it is blocked, or deleting ethernet configuration from /etc/network/interfaces so that it works with connman (or at least give the option).
I understand if I am asking you to perform too many tests and you don’t want to. I am really sorry that the script is giving you problems. I will try and figure out how to better help with this situation.
antiX Live system enthusiast.
General Live Boot Parameters for antiX.September 15, 2020 at 3:21 am #41710Forum Admin
anticapitalista
::Thanks for the runit feedback. Good to know the script works.
Not all ethernet shows as eth0 and not all wlan as wlan0.
Perhaps this might be an issue?
Still haven’t had time to test the script.Philosophers have interpreted the world in many ways; the point is to change it.
antiX with runit - leaner and meaner.
September 15, 2020 at 7:42 am #41721Memberex_Koo
::@Xecure
Don’t worry it may have been my installed antiX, have not used the laptop for about a year or more as I give my desktop to one of my son’s and have upgraded the T430 to i7 and more memory with the same version of antiX still installed.
Earlier I did a fresh install of antiX-19 runit base x64 and everything is working good now, but connman seemed to be not install on the base version. Just running my internet with ceni I will keep things the way they are for the time being, will wait for more development with connman and the switching script.
I blame myself for the problems I was having with connman and the script.
Xecure just keep up your good work and endeavor to make antiX even better. Thanks You
Thanks for your feed back anticapitalista.
September 15, 2020 at 1:40 pm #41730Member
Xecure
::I blame myself for the problems I was having with connman and the script.
I found out it is my fault. You reported:
Restarting networking service
[warn] Running /etc/init.d/networking restart is deprecated because it may not re-enable some
[ ok ] Reconfiguring network interfaces… eth0 done.
Stopping all wpa_supplicant processesIf I stop wpa_supplicant before restarting the networking service this problem doesn’t pop up (using ceni). I have added the fix in the next version.
So I rebooted again still with ceni in control no internet again
I finally experienced the same issue after restarting a few times, but I could not reproduce it again after that (it was a one time thing for me, even after many more tries). The solution was restarting the networking service. I thought I could get it to happen again, so I didn’t check the service status or if wpa_supplicant was off (the two possible reason I assume could cause the error). I cannot really confirm what the reason was.
Anyway, having changed the order of some instructions in the switch_to_ceni function, as reported above, if you use the switch to re-select ceni, it should reconnect to the wifi using the ceni configuration (as it was already set up previously) without having to give the ceni info again.About the other changes, I followed most of Dave’s recommendations. I now remember why I had set the unblock using connman by default if installed. Even if you rfkill unblock wifi, next time you launch connman it will remember connman’s last setting and re-block the wifi network (as reported by rokytnji on previous posts on this forum). It is always better, if possible, to use connman to unblock the wifi so that we are sure next time we switch network manager we don’t have a strange behavior.
Thanks again for all the feedback provided. I think i am improving the script little by little.
Attachments:
antiX Live system enthusiast.
General Live Boot Parameters for antiX.September 15, 2020 at 2:07 pm #41735Moderator
Brian Masinick
::Have not tested this script, but I am glad to see one being made!
For me it is the same situation as SamK really.
Some helpful suggestions after a quick glance at the github page.
– checks a suchif [[ "$SWITCH_NM" != "" ]]; thenmay be better to use the test function -n or !-z (a test list: https://tldp.org/LDP/Bash-Beginners-Guide/html/sect_07_01.html)
– In the check installed function you might consider using a case statement to make it easier to add other network management tools if wanted in the future. (wicd/network-manager/etc)
– Along with the warning about a missing resolv.conf… add a link to the one that will work for the chosen setup with a message that this was done and how to remove.
– Along with the echo messages, consider making the calls functions to echo (example error “this is the error”) so you can use logging as well (very helpful in troubleshooting if run from the control centre without terminal). Example:log_file="$HOME/.wifi-switcher.log" function error { echo "ERROR: $@" |tee -a $log_file } function warn { echo "WARNING: $@" }– I have not tested but from reading it seems if the wifi is soft blocked and you are switching to ceni with the default antix setup (connman installed) it will try to kill and run connman to unblock the wifi before starting ceni
switch_to_ceni(){ echo $"Switching to ceni" # 0. Enable Wifi enable_wifi && sleep 2enable_wifi(){ # Check if wifi is locked and unlock if possible. if [ $(rfkill list wifi | grep -c "Soft blocked: yes" 2>/dev/null) -gt 0 ]; then echo $"Wi-Fi softblocked." # ask for sudo password # Use connmanctl (if installed) to enable wifi if [ -x /usr/bin/connmanctl ]; thenperhaps consider adding switches to the function to bypass the test. Example (though probably not the best way):
function enable_wifi() { case $1 in ceni) use_connman=0; use_rfkill=1;; connman) use_connman=1; use_rfkill=1;; *) use_connman=0; use_rfkill=1;; esac }– The hardblock check is probably better to be in the check_wifi function to avoid duplication
– The default PROGRAM_INTERFACE=”” declaration may be better set in the if DISPLAY test.
– Likewise and with the above point, maybe check for yad in the same if statement via ||
– Not 100% certain on the necessity of the export declarations, but IIRC they should be written like variable=item; export variable; rather than export variable=item;My only question on the coding recommended is why the same assignment is repeated for all cases –
use_rfkill=1?
Why not place this assignment outside of the case statement and assign the value only once?
--
Brian MasinickSeptember 16, 2020 at 8:00 pm #41795Forum Admin
Dave
::My only question on the coding recommended is why the same assignment is repeated for all cases –
use_rfkill=1?
Why not place this assignment outside of the case statement and assign the value only once?
Mainly because it was an example way (and probably not the best one 😉 ) to avoid running code if it was chosen not to use it (connman in this case) as well as make it easier to expand if there was to be another network manager added (network-manager, wpa_gui, wicd?). Secondly because that is how the script read when I first looked at it, using rfkill as a fallback. It would check for connman, use connman, if connman failed use rfkill, check if rfkill worked.
Computers are like air conditioners. They work fine until you start opening Windows. ~Author Unknown
September 17, 2020 at 10:41 am #41809Moderator
Brian Masinick
::How about this?
function enable_wifi() { case $1 in ceni) use_connman=0;; connman) use_connman=1;; *) use_connman=0;; esac use_rfkill=1;; }--
Brian MasinickSeptember 17, 2020 at 12:55 pm #41812Member
Xecure
::Mainly because it was an example way
How about this?
It is unnecesary to continue this discussion. I have opted to leave the “always unlock with connman if available” for the reason stated in a previous comment. If I unlock with rfkill first, next time I launch connman it will remember its last configuration (wifi off) and dissable the wifi. This will not help people who don’t know that they need to unblock (enable) the wifi using the connman switch (they were expecting it to be unblocked by default or that wifi would be enabled with the switch script).
antiX Live system enthusiast.
General Live Boot Parameters for antiX. -
AuthorPosts
- You must be logged in to reply to this topic.