You are not logged in.

#1 2013-10-17 17:14:47

PHF
Member
Registered: 2013-10-17
Posts: 8

[SOLVED] network-online.target is reached too early

Hi,

I want to start a systemd service once my wireless card is correctly set up (especially the wifi channel).
I think that the network-online is what I need.
So, I added the following lines at the beginning of my service file :

[Unit]
Description=...
Wants=network-online.target
After=network-online.target

...

However, it seems that the network-online.target is reached really early in the boot process, far before the discovery of the wireless card.

I don't know if it's important, but my wireless network is configured with netctl-auto.

I'm not very familiar with systemd, so I don't even understand how network-online.target is supposed to be notified that the network is online.
So, any help would be apreciated.

Thanks.

PS : I hope my approximative English is understandable enough.

Last edited by PHF (2013-10-28 02:51:43)

Offline

#2 2013-10-23 02:42:33

railmaniac
Member
Registered: 2010-04-24
Posts: 24

Re: [SOLVED] network-online.target is reached too early

Is the other service failing because of this? What is the other service and what error are you getting?

Also, this might be useful: http://www.freedesktop.org/wiki/Softwar … orkTarget/


Thanks,
railmaniac

Offline

#3 2013-10-24 20:19:41

PHF
Member
Registered: 2013-10-17
Posts: 8

Re: [SOLVED] network-online.target is reached too early

Thanks for your reply.

The other service is a hostapd daemon which runs on the same wireless card than the internet connectivity (using a virtual interface).
To get it to work, I need to set the access point on the same wifi channel than the wireless network to which I'm already connected.

Thanks to netctl-auto, I'm able to let the system selecting one of the preconfigured wireless networks.
However, I need to know when one has been selected in order to get the current wifi channel and then properly configure my hostapd daemon.

It seems that NetworkManager-wait-online.service does the job for people using NetworkManager, but what about netctl(-auto)?

Offline

#4 2013-10-25 11:07:35

railmaniac
Member
Registered: 2010-04-24
Posts: 24

Re: [SOLVED] network-online.target is reached too early

Can you try this?

[Unit]
...
Requires=network-online.target
After=netctl-auto@interface.service
...

where interface is your wireless interface, or virtual interface, and various combinations thereof? Also try switching around the requires and after...


Thanks,
railmaniac

Offline

#5 2013-10-25 17:54:18

PHF
Member
Registered: 2013-10-17
Posts: 8

Re: [SOLVED] network-online.target is reached too early

I tried your suggestions but it didn't worked.
My service is well ordered after netctl-auto, but netctl-auto doesn't wait that a first connection is established.
So my service is still started before the wireless interface is configured.

Also, network-online.target is still triggered at the early beginning of the systemd boot process.
It is as if nothing was ordered before network-online.target.

Offline

#6 2013-10-26 12:24:50

Lone_Wolf
Member
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 11,868

Re: [SOLVED] network-online.target is reached too early

NetworkManager-wait-online.service

[Unit]
Description=Network Manager Wait Online
Requisite=NetworkManager.service
After=NetworkManager.service
Wants=network.target
Before=network.target network-online.target

[Service]
Type=oneshot
ExecStart=/usr/bin/nm-online -q --timeout=30

[Install]
WantedBy=multi-user.target

as you can see, the NetworkManager-wait-online.service does very little, it just starts the nm-online command.



PHF, if i understand correctly you need to be sure the wireless connection is up and configured before the hostapd daemon runs ?

a solution to achieve this might be to write a special command to check if the connection is up and add a service for it like the NetworkManager-wait-online.service .
This special command could be simple, like grepping the output op of ip addr show <interfacename> in a loop until it has a valid ip address.


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.


(A works at time B)  && (time C > time B ) ≠  (A works at time C)

Offline

#7 2013-10-26 13:06:58

PHF
Member
Registered: 2013-10-17
Posts: 8

Re: [SOLVED] network-online.target is reached too early

Lone_Wolf wrote:

PHF, if i understand correctly you need to be sure the wireless connection is up and configured before the hostapd daemon runs ?

Yes, exactly.

Lone_Wolf wrote:

a solution to achieve this might be to write a special command to check if the connection is up and add a service for it like the NetworkManager-wait-online.service .
This special command could be simple, like grepping the output op of ip addr show <interfacename> in a loop until it has a valid ip address.

Well, that's what I started to guess, without certitude : I need to manually order a waiting service before network-online.target.
I think my problem is solved now smile.

Meanwhile, I have found the ExecUpPost option for my netctl profiles.
It gives me the ability to execute a command once the connection is active.
So, I should be able to use it for unlocking my waiting service.

Thanks a lot for your help.

Offline

Board footer

Powered by FluxBB