normally it is possible to change to order/dependencies of services as described here.
Furthermore one can automatically connect with either Ethernet (net-auto-wired.service) or Wlan (net-auto-wireless.service) at boot.
Currently I enabled hostapd.service. However, I only want to start it, if I am connected with ethernet and not wlan.
If I am connected with wlan, i don't want to start hostapd.
And I want to automatically connect to ethernet, if it is available. Otherwise to a known wlan hotspot.
I don't really know how to solve that problem.
Thanks for any help,
To answer the question in the title of the thread, you probably want the "Requires=net-auto-wired.service" entry in hostpad.service.
Prioritizing wired over wireless would be configured in your network management. Is this netcfg?
Yes I use netcfg.
Should I enable both "net-auto-wired.service" and "net-auto-wireless.service" at the same time?
Last edited by kpj (2012-12-30 12:30:00)
That I'm not sure of, which I why I only addressed the one part of the question - I've never used netcfg.
Oh okay, what do you use instead?
I don't use any network management tools. Netcfg is what you would want for this. I'm just not the one to advise how to configure it.
Last edited by Trilby (2012-12-30 14:39:21)
With netcfg you can define commands being issued after the network is up and before it is down (and before it is up and after it is down works as well).
As an example, I have these two lines
POST_UP="/bin/su - army -l -c 'transmission-daemon --pid-file /tmp/transmission.pid'" PRE_DOWN="killall -w transmission-daemon"
in both my profiles. The commands are being run as root, so you could insert something like
POST_UP="systemd start SERVICE.service" PRE_DOWN="systemd stop SERVICE.service"
But I think this isn't a very nice solution This should also be possible within systemd with the options it provides.
Last edited by Army (2012-12-30 16:59:11)
Thanks a lot for your help, even if it is not a "nice" solution ;-)
I'll definitely try it out!
POST_UP="systemctl start hostapd.service"
Last edited by kpj (2012-12-30 22:40:33)
The lines under [UNIT] here have been altered, been watching it in journalctl -b , it's doing exactly what I want it to and no one here seems to have anything negative to say about it, figure out where the services files are by doing systemctl status <service>. Just make use of WANTS/AFTER as you need them. You probably need something like "AFTERemail@example.com" in the unit of service you want to wait for eth0 to be up, whatever its profile name is.
Last edited by Never (2012-12-30 23:09:20)