You are not logged in.
Hi all,
I was trying out a couple of things today, one of which was using nmcli to connect my laptop to my WiFi network immediately after autologin. Well, nmcli (kinda unexpectedly) errored out with:
Arch Linux 4.12.8-2-ARCH (tty1)
pulpit login: bo (automatic login)
(process:516): GLib-GIO-WARNING **: gdbusobjectmanagerclient.c:1585: Processing InterfaceRemoved signal for path /org/freedesktop/NetworkManager/IP4Config/1 but no object proxy exists
(process:516): GLib-GIO-WARNING **: gdbusobjectmanagerclient.c:1585: Processing InterfaceRemoved signal for path /org/freedesktop/NetworkManager/IP6Config/1 but no object proxy exists
Error: No network with SSID 'JackUnterweger' found.
I issued the command again, manually. It worked. Joy. And, yes, it occurs to me that I could(?) deal with this by doing:
# Get WiFi up with nmcli.
echo -e "\n\033[1;36m---+++ Starting WiFi +++---\033[0m"
while true; do
if nmcli dev wifi connect JackUnterweger password BestSerialKillerEver ; then
echo "WiFi Up."
break
else
echo "Retrying.." ; sleep 1
fi
done
But I played around a bit more, seeing that a brief pause seemed necessary between my autologin and the issuing of the nmcli command. I am guessing that nmcli depends upon something else to be up and running first. Could someone help interpret those error messages for me?
I looked up the ArchWiki on NetworkManager (https://wiki.archlinux.org/index.php/NetworkManager) and it mentions that NetworkManager.service mightn't come up immediately (or words I took to that effect), and so I guessed a bit more and concluded (probably wrongly) that my little difficulty might be because of this. The ArchWiki states that NetworkManager-dispatcher.service can be used as a scheduler to get around timing problems.
Therefore, as root, I did:
systemctl enable NetworkManager-dispatcher.service
Having first placed a script (0755 root root) called 00_abcd in /etc/NetworkManager/dispatcher.d/. This script (which is just a test) consists of:
#!/bin/bash
# 00_abcd
echo -e "Time: $(date +%s) Interface: $1 Status: $2" >> /stuff/iwh
I rebooted and autologin-ed as normal. I simple-mindedly expected iwh to read: "Time: 150XXXXXXX Interface: wlp58s0 Status: up" (after which I'd be able to get nmcli to do its business).
It didn't. It read: "Time: 150XXXXXXX Interface: none Status: hostname"
<Sigh>. Before I go on, could some kind soul tell me whether it's actually worth it? Am I barking up entirely the wrong tree? I imagined that the idea of the dispatcher service would be to trigger stuff once all is good and ready to go. But it's obviously not that simple. I cycled the laptop with a few reboots, aware that the results would be appended to the iwh file. Would there be evidence of further trigger events/status conditions? Apparently so - here's iwh now:
Time: 1504624786 Interface: wlp58s0 Status: up
Time: 1504624787 Interface: Status: connectivity-change
Time: 1504624853 Interface: Status: connectivity-change
Time: 1504624853 Interface: wlp58s0 Status: down
Time: 1504624889 Interface: wlp58s0 Status: up
Time: 1504624890 Interface: Status: connectivity-change
Time: 1504624978 Interface: Status: connectivity-change
Time: 1504624978 Interface: wlp58s0 Status: down
Time: 1504624994 Interface: wlp58s0 Status: up
Time: 1504624995 Interface: Status: connectivity-change
Time: 1504625099 Interface: none Status: hostname
Time: 1504625106 Interface: wlp58s0 Status: up
Time: 1504625107 Interface: Status: connectivity-change
Time: 1504625198 Interface: none Status: hostname
Time: 1504625210 Interface: wlp58s0 Status: up
Time: 1504625211 Interface: Status: connectivity-change
Time: 1504625635 Interface: none Status: hostname
Time: 1504625647 Interface: wlp58s0 Status: up
Time: 1504625648 Interface: Status: connectivity-change
Time: 1504625689 Interface: none Status: hostname
Time: 1504625701 Interface: wlp58s0 Status: up
Time: 1504625702 Interface: Status: connectivity-change
Can anyone suggest what I should be doing to ensure the timely (proper?) execution of the nmcli command?
Thanks,
Loady
Last edited by loadlover (2017-09-08 22:23:34)
Offline
I guess I'll follow up here. Additional to the above, I added a test script to the /etc/NetworkManager/dispatcher.d/pre-up.d/ directory. This one is very similar to the other. It reads:
#!/bin/bash
# 00_abcd
echo -e "Time: $(date +%s) Interface: $1 Status: $2" >> /stuff/iwh-up
Now, after a fresh Arch install, and despite enabling NetworkManager.service and NetworkManager-dispatcher.service, only the script in /etc/NetworkManager/dispatcher.d/ is excuted upon system startup. The result is the
"Time: 150XXXXXXX Interface: none Status: hostname"
message over and over with every subsequent reboot. Fantastic. *Then* I *manually* fire up my WiFi interface with the usual
nmcli dev wifi connect JackUnterweger password BestSerialKillerEver
And now both scripts are executed.
Great. I have to get the interface going *manually first* to get the triggers to work, the triggers that *should* be providing the method to get the interface going *in the first place*...
Oy vey.
Loady
Last edited by loadlover (2017-09-07 11:45:12)
Offline
NetworkManager-dispatcher.service is the wrong tool for this and the Arch wiki makes no such mention (the timeout you mistake for helping with this, is for the case that the scripts that are being executed take longer to execute), of this being the case. It's to react to the event of a certain network being used, not to set up the connection. You could simply define this "main connection" as a persistent connection profile
man nmcli
which will make NetworkManager connect to it automatically on login/bootup (if configured as a system connection ). Alternatively you could do
nmcli dev wifi-rescan JackUnterweger
nmcli dev wifi connect JackUnterweger password BestSerialKillerEver
which should lead to the correct result as well. I suspect that currently the wifi connect command simply misses the SSID scan window. But yeah, making a connection profile for often used connections is the intended way to go with NetworkManager.
Offline
Thanks. Appreciated.
Loady
Offline