You are not logged in.
Pages: 1
I've created a systemd service that's supposed to check for my uni network on startup. When I have logged in and got into i3 and run the service with "sudo systemctl start eduroam_scan.service" it works as intended, but when run by systemctl at boot it doesn't work.
The service is:
[Unit]
Description=Eduroam Scan
After=network.target
After=systemd-user-sessions.service
After=dhcpcd.service
After=wpa_supplicant.service
[Service]
Type=forking
ExecStart=/home/chop1n/.scripts/eduroamscript.sh
[Install]
WantedBy=multi-user.targetAnd the script that is run is:
#!/bin/bash
if [[ $(nmcli dev wifi | grep -l eduroam) ]]; then
wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf
else
echo "Network not found, likely not available"
output =$(wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf)
echo "${output}"
fiAfter startup "systemctl status eduroam_scan.service" returns:
● eduroam_scan.service - Eduroam Scan
Loaded: loaded (/etc/systemd/system/eduroam_scan.service; enabled; vendor preset: disabled)
Active: inactive (dead) since Mon 2020-11-09 10:31:18 GMT; 15min ago
Process: 671 ExecStart=/home/chop1n/.scripts/eduroamscript.sh (code=exited, status=0/SUCCESS)
Nov 09 10:31:18 ArchThink systemd[1]: Starting Eduroam Scan...
Nov 09 10:31:18 ArchThink eduroamscript.sh[671]: Network not found, likely not available
Nov 09 10:31:18 ArchThink eduroamscript.sh[714]: /home/chop1n/.scripts/eduroamscript.sh: line 7: output: command not found
Nov 09 10:31:18 ArchThink systemd[1]: eduroam_scan.service: Succeeded.
Nov 09 10:31:18 ArchThink systemd[1]: Started Eduroam Scan.I'm wonder if it isn't possible to run wpa_supplicant command like this at boot. Does anyone know how to either fix this service or how I can work around it.
Any help is much appreciated!
Last edited by Chop1n (2020-11-09 12:50:28)
"curl -F 'sprunge=<-' http://sprunge.us < path-to-file" is holy
Offline
For the literal error, the script seems to run, but you shouldn't have a space between the variable and the = sign of the value assignment in output.
That said why would you use nmcli to check for network devices and then not just use networkmanager and not have to do any of this? If this is a purely theoretical exercise this seems like a bad example.
Generally there's a lot of weirdness here in terms of the actual service. You "seem" to want it run as an user service, declare it as a system service and then declare it to start after certain services, while using a directly conflicting service as part of the script (... you want neither wpa_supplicant nor dhcpcd running in an enabled context if you use networkmanager, so the after conditions will be largely irrelevant)
If this isn't just a theoretical exercise maybe try to explain what your end goal is here, do you just want a message in your journal if eduroam is present or what's the goal?
Last edited by V1del (2020-11-09 11:06:55)
Online
For the literal error, the script seems to run, but you shouldn't have a space between the variable and the = sign of the value assignment in output.
That said why would you use nmcli to check for network devices and then not just use networkmanager and not have to do any of this? If this is a purely theoretical exercise this seems like a bad example.
Generally there's a lot of weirdness here in terms of the actual service. You "seem" to want it run as an user service, declare it as a system service and then declare it to start after certain services, while using a directly conflicting service as part of the script (... you want neither wpa_supplicant nor dhcpcd running in an enabled context if you use networkmanager, so the after conditions will be largely irrelevant)
If this isn't just a theoretical exercise maybe try to explain what your end goal is here, do you just want a message in your journal if eduroam is present or what's the goal?
It's not just a theoretical exercise, the purpose is to check if my uni network is available and if it is I want it to run that wpa supplication command to connect, the else is currently only there for debugging. And to why I'm using wpa supplication to connect it is simply what has worked for me, I previously tried to get it to work with network manager but had no luck. This wpa supplication command + config works fine for me when running it in the terminal,but the goal is to auto connect on boot if the network is available. But I don't want it to run the script at all if eduroam isn't present. Thank you
After fixing the output in the script to look like:
#!/bin/bash
if [[ $(nmcli dev wifi | grep -l eduroam) ]]; then
wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf
else
echo "Network not found, likely not available"
output=$(wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf)
echo "${output}"
echo "______________________________"
output2=$(nmcli dev wifi | grep -l eduroam)
echo "${output2}"
fiNow when I check "systemctl status eduroam_scan" I get:
● eduroam_scan.service - Eduroam Scan
Loaded: loaded (/etc/systemd/system/eduroam_scan.service; enabled; vendor preset: disabled)
Active: inactive (dead) since Mon 2020-11-09 13:14:53 GMT; 54s ago
Process: 689 ExecStart=/home/chop1n/.scripts/eduroamscript.sh (code=exited, status=0/SUCCESS)
Nov 09 13:14:53 ArchThink eduroamscript.sh[689]: Network not found, likely not available
Nov 09 13:14:53 ArchThink eduroamscript.sh[689]: Successfully initialized wpa_supplicant
Nov 09 13:14:53 ArchThink eduroamscript.sh[689]: Could not read interface wlan0 flags: No such device
Nov 09 13:14:53 ArchThink eduroamscript.sh[689]: nl80211: Driver does not support authentication/association or connect commands
Nov 09 13:14:53 ArchThink eduroamscript.sh[689]: nl80211: deinit ifname=wlan0 disabled_11b_rates=0
Nov 09 13:14:53 ArchThink eduroamscript.sh[689]: Could not read interface wlan0 flags: No such device
Nov 09 13:14:53 ArchThink eduroamscript.sh[689]: wlan0: Failed to initialize driver interface
Nov 09 13:14:53 ArchThink eduroamscript.sh[689]: _______________________________
Nov 09 13:14:53 ArchThink systemd[1]: eduroam_scan.service: Succeeded.
Nov 09 13:14:53 ArchThink systemd[1]: Started Eduroam Scan.And I get no output from "nmcli dev wifi | grep -l eduroam" because the network couldn't be found. With these errors I assume it doesn't run because the wlan0 device hasn't been set to up yet. Is there any way to set the service to run after the wlan0 device is up?
Last edited by Chop1n (2020-11-09 12:27:36)
"curl -F 'sprunge=<-' http://sprunge.us < path-to-file" is holy
Offline
Okay solved it.
Solution was to in the service replace "After=network.target" to "After=network-online.target". Now it runs properly.
Thanks for the help V1del!
"curl -F 'sprunge=<-' http://sprunge.us < path-to-file" is holy
Offline
That's technically not quite correct and just doesn't make a lot of sense. network-online.target will only trigger when you are already connected to something that gives you an IP address. The entire point of NetworkManager is to do this automatically so you are just doing twice the work for little to no actual real gain and might even run into issues doing it that way. NetworkManager can and does remember the networks you've connected to and will automatically connect to an eduroam, without invoking this script of yours.
In essence with that adjustment, your script runs when you are already connected anyway, and you simply run a wpa_supplicant command that hopefully errors out instead of breaking the existing working connection.
Last edited by V1del (2020-11-09 12:42:54)
Online
But it doesn't connect without the wpa_supplicant command, so I don't know how networkmanager could have connected on its own. I don't even think networkmanager can connect to eduroam networks without some configuring. The cat.eduroam.org website list a configuration tool which I ran but it has failed every time to produce a networkmanager config so I've instead been using wpa_supplicant. How would I figure out why this works?
"curl -F 'sprunge=<-' http://sprunge.us < path-to-file" is holy
Offline
That depends on what you've done in general to configure this, maybe check/post a journal log so we have an actual idea of what's happening and which services are currently actively enabled
find /etc/systemd -type l -exec test -f {} \; -print | awk -F'/' '{ printf ("%-40s | %s\n", $(NF-0), $(NF-1)) }' | sort -f
sudo journalctl -b.
From how I'm reading your scripts general flow, you have at the very least networkmanager enabled (... you wouldn't be able to use nmcli without it) and I suspect that to actually end up doing the correct thing regardless of what you are attempting to do.
Online
find /etc/systemd -type l -exec test -f {} \; -print | awk -F'/' '{ printf ("%-40s | %s\n", $(NF-0), $(NF-1)) }' | sort -f
bluetooth.service | bluetooth.target.wants
dbus-org.bluez.service | system
dbus-org.freedesktop.nm-dispatcher.service | system
dhcpcd.service | multi-user.target.wants
dirmngr.socket | sockets.target.wants
display-manager.service | system
eduroam_scan.service | multi-user.target.wants
getty@tty1.service | getty.target.wants
gpg-agent-browser.socket | sockets.target.wants
gpg-agent-extra.socket | sockets.target.wants
gpg-agent.socket | sockets.target.wants
gpg-agent-ssh.socket | sockets.target.wants
iwd.service | multi-user.target.wants
NetworkManager.service | multi-user.target.wants
NetworkManager-wait-online.service | network-online.target.wants
nmb.service | multi-user.target.wants
p11-kit-server.socket | sockets.target.wants
pulseaudio.socket | sockets.target.wants
remote-fs.target | multi-user.target.wants
smb.service | multi-user.target.wants
tlp.service | multi-user.target.wantssudo journalctl -b"curl -F 'sprunge=<-' http://sprunge.us < path-to-file" is holy
Offline
You have multiple services of potentially conflicting daemons installed. I'm assuming you didn't configure networkmanager to use iwd otherwise you'd not be trying to use wpa_supplicant manually. Decide for what you want to use disable the others, assuming networkmanager, disable dhcpcd and iwd (... and your own eduroam service, because as expected it's
Nov 09 14:13:33 ArchThink systemd[1]: Starting Eduroam Scan...
Nov 09 14:13:33 ArchThink systemd[1]: Starting Samba NMB Daemon...
Nov 09 14:13:33 ArchThink eduroamscript.sh[1358]: Successfully initialized wpa_supplicant
Nov 09 14:13:33 ArchThink eduroamscript.sh[1358]: nl80211: kernel reports: Match already configured
Nov 09 14:13:33 ArchThink eduroamscript.sh[1358]: nl80211: kernel reports: Match already configured
Nov 09 14:13:33 ArchThink eduroamscript.sh[1358]: nl80211: kernel reports: Match already configured
Nov 09 14:13:33 ArchThink eduroamscript.sh[1358]: nl80211: kernel reports: Match already configured
Nov 09 14:13:33 ArchThink eduroamscript.sh[1358]: nl80211: kernel reports: Match already configured
Nov 09 14:13:33 ArchThink eduroamscript.sh[1358]: nl80211: kernel reports: Match already configured
Nov 09 14:13:33 ArchThink eduroamscript.sh[1358]: nl80211: kernel reports: Match already configured
Nov 09 14:13:33 ArchThink eduroamscript.sh[1358]: nl80211: kernel reports: Match already configured
Nov 09 14:13:33 ArchThink eduroamscript.sh[1358]: nl80211: kernel reports: Match already configured
Nov 09 14:13:33 ArchThink eduroamscript.sh[1358]: nl80211: kernel reports: Match already configured
Nov 09 14:13:33 ArchThink eduroamscript.sh[1358]: nl80211: kernel reports: Match already configured
Nov 09 14:13:33 ArchThink eduroamscript.sh[1358]: nl80211: kernel reports: Match already configured
Nov 09 14:13:33 ArchThink eduroamscript.sh[1358]: nl80211: kernel reports: Match already configured
Nov 09 14:13:33 ArchThink eduroamscript.sh[1358]: nl80211: kernel reports: Match already configured
Nov 09 14:13:33 ArchThink eduroamscript.sh[1358]: nl80211: kernel reports: Match already configured
Nov 09 14:13:33 ArchThink eduroamscript.sh[1358]: nl80211: kernel reports: Match already configured
Nov 09 14:13:33 ArchThink eduroamscript.sh[1358]: nl80211: kernel reports: Match already configured
Nov 09 14:13:33 ArchThink eduroamscript.sh[1358]: nl80211: kernel reports: Match already configured
Nov 09 14:13:33 ArchThink eduroamscript.sh[1358]: nl80211: kernel reports: Match already configured
Nov 09 14:13:33 ArchThink eduroamscript.sh[1358]: nl80211: kernel reports: Match already configured
Nov 09 14:13:33 ArchThink eduroamscript.sh[1358]: nl80211: kernel reports: Match already configured
Nov 09 14:13:33 ArchThink eduroamscript.sh[1358]: nl80211: kernel reports: Match already configured
Nov 09 14:13:33 ArchThink eduroamscript.sh[1358]: nl80211: kernel reports: Match already configured
Nov 09 14:13:33 ArchThink eduroamscript.sh[1358]: nl80211: kernel reports: Match already configured
Nov 09 14:13:33 ArchThink nmbd[1351]: [2020/11/09 14:13:33.208600, 0] ../../lib/util/become_daemon.c:147(daemon_status)
Nov 09 14:13:33 ArchThink nmbd[1351]: daemon_status: daemon 'nmbd' : No local IPv4 non-loopback interfaces available, waiting for interface ...
Nov 09 14:13:33 ArchThink nmbd[1351]: [2020/11/09 14:13:33.208984, 0] ../../source3/nmbd/nmbd_subnetdb.c:253(create_subnets)
Nov 09 14:13:33 ArchThink nmbd[1351]: NOTE: NetBIOS name resolution is not supported for Internet Protocol Version 6 (IPv6).
Nov 09 14:13:33 ArchThink kernel: debugfs: Directory 'netdev:p2p-dev-wlan0' with parent 'phy0' already present!
Nov 09 14:13:33 ArchThink eduroamscript.sh[1358]: nl80211: Could not set interface 'p2p-dev-wlan0' UP
Nov 09 14:13:33 ArchThink eduroamscript.sh[1358]: nl80211: deinit ifname=p2p-dev-wlan0 disabled_11b_rates=0
Nov 09 14:13:33 ArchThink eduroamscript.sh[1358]: p2p-dev-wlan0: Failed to initialize driver interface
Nov 09 14:13:33 ArchThink eduroamscript.sh[1358]: P2P: Failed to enable P2P Device interface
Nov 09 14:13:33 ArchThink systemd[1]: Started Eduroam Scan.not actually doing anything useful.
Online
Pages: 1