On Wed, May 02, 2012 at 03:40:57PM -0700, David Strauss wrote: > On Wed, May 2, 2012 at 1:19 PM, Sebastian Tramp > <[email protected]> wrote: > > Are there existing service files which solve a similar or the same issue? > > You may want a target [1]. There is already a network target, but I > believe it comes up before NetworkManager fully initializes all > interfaces. I would consider adding a script that fires > network-fully-up.target once NetworkManager finishes [2].
Hi David, ok thank- using a NetworkManagers dispatch script in combination with
a systemd target is definitely the way to go here.
#!/bin/bash
# /etc/NetworkManager/dispatcher.d/99-systemd-network-fully-up
INTERFACE=$1
ACTION=$2
case "$ACTION" in
up)
systemctl start network-is-up.target
;;
down)
systemctl stop network-is-up.target
;;
esac
> This would allow any service to install as "WantedBy" that target.
yes, starting network-is-up correctly starts fetchmail.service now.
> It's probably also possible to stop the network-fully-up.target on
> disconnection. If services indicating WantedBy=network-fully-up.target also
> have StopWhenUnneeded enabled, they will shut down on stopping that target.
this does not work for me currently. here is my fetchmail.service file. Maybe
you can review it?
[Unit]
Description=Fetchmail
[Service]
Type=simple
ExecStart=/usr/bin/fetchmail --idle
WorkingDirectory=/home/seebi
User=seebi
Group=seebi
StandardOutput=journal
StandardError=journal
StopWhenUnneeded=yes
[Install]
WantedBy=network-is-up.target
> Altogether, this should do what you need as well as provide a general
> facility on your systems for any unit to start and stop based on network
> availability.
> Note: For a target like network-fully-up, it would be bad to try and use
> systemctl isolate in the same way as for the runlevels.
means I should add AllowIsolate=false? Currently my network-is-up.target
consists only of these lines:
[Unit]
Description=Network is fully available
Thank you and Best regards
Sebastian Tramp
> [1] http://0pointer.de/public/systemd-man/systemd.target.html
> [2]
> http://drewdahl.com/2011/05/03/using-networkmanager-to-run-scripts-after-connecting/
--
WebID: http://sebastian.tramp.name
pgpCSkgZa10sZ.pgp
Description: PGP signature
_______________________________________________ systemd-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/systemd-devel
