Re: [gentoo-user] systemd how can I get a service to start after network is up

2014-05-20 Thread Michael Hampicke
Am 20.05.2014 12:29, schrieb cov...@ccs.covici.com:
> Hi.  I have a simple, static, ethernet network.  However when booting
> using systemd, a number of services which should start only after the
> network is up, insist on starting in parallell and so fail for various
> reasons.  Here is my network service and my ntpdate service file, and I
> would like to know how to get the ntpdate service file to wait till the
> network is up before trying to start.
> 
> Thanks in advance for any suggestions.
> 
> Network service file:
> [Unit]
> Description=Network Connectivity for %i
> Documentation= nam ip
> Before=network.target
> wants=network.target
> BindsTo=sys-subsystem-net-devices-%i.device
> After=sys-subsystem-net-devices-%i.device
> [Service]
> Type=oneshot
> RemainAfterExit=yes
> EnvironmentFile=/etc/conf.d/network@%i
> ExecStart=/bin/ip link set dev %i up
> ExecStart=/bin/ip addr add ${address}/${netmask} broadcast ${broadcast} dev %i
> ExecStart=-/bin/bash -c "test -n ${gateway} && /bin/ip route add default via 
> ${gateway}"
> ExecStart=-/bin/bash -c "test -f /etc/conf.d/postup@%i.sh&&/bin/bash  -c 
> /etc/conf.d/postup@%i.sh"
> ExecStop=/bin/ip addr flush dev %i
> ExecStop=/bin/ip link set dev %i down
> [Install]
> WantedBy=multi-user.target
> 
> and here is my ntpdate service file:
> 
> [Unit]
> Description=Set time via NTP using ntpdate
> After=network.target nss-lookup.target
> Before=time-sync.target
> Wants=time-sync.target
> 
> [Service]
> Type=oneshot
> EnvironmentFile=/etc/conf.d/ntp-client
> ExecStart=/usr/sbin/ntpdate $NTPCLIENT_OPTS
> RemainAfterExit=yes
> 
> [Install]
> WantedBy=multi-user.target
> 

Hi there,

setting "After=network.target" should just work (tm). I have a few
custom service files which need a working network connection, and using
this setting words for me.

systemd-analyze plot > boot.svg also shows the these services only start
after the network is up.



signature.asc
Description: OpenPGP digital signature


[gentoo-user] systemd how can I get a service to start after network is up

2014-05-20 Thread covici
Hi.  I have a simple, static, ethernet network.  However when booting
using systemd, a number of services which should start only after the
network is up, insist on starting in parallell and so fail for various
reasons.  Here is my network service and my ntpdate service file, and I
would like to know how to get the ntpdate service file to wait till the
network is up before trying to start.

Thanks in advance for any suggestions.

Network service file:
[Unit]
Description=Network Connectivity for %i
Documentation= nam ip
Before=network.target
wants=network.target
BindsTo=sys-subsystem-net-devices-%i.device
After=sys-subsystem-net-devices-%i.device
[Service]
Type=oneshot
RemainAfterExit=yes
EnvironmentFile=/etc/conf.d/network@%i
ExecStart=/bin/ip link set dev %i up
ExecStart=/bin/ip addr add ${address}/${netmask} broadcast ${broadcast} dev %i
ExecStart=-/bin/bash -c "test -n ${gateway} && /bin/ip route add default via 
${gateway}"
ExecStart=-/bin/bash -c "test -f /etc/conf.d/postup@%i.sh&&/bin/bash  -c 
/etc/conf.d/postup@%i.sh"
ExecStop=/bin/ip addr flush dev %i
ExecStop=/bin/ip link set dev %i down
[Install]
WantedBy=multi-user.target

and here is my ntpdate service file:

[Unit]
Description=Set time via NTP using ntpdate
After=network.target nss-lookup.target
Before=time-sync.target
Wants=time-sync.target

[Service]
Type=oneshot
EnvironmentFile=/etc/conf.d/ntp-client
ExecStart=/usr/sbin/ntpdate $NTPCLIENT_OPTS
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

-- 
Your life is like a penny.  You're going to lose it.  The question is:
How do
you spend it?

 John Covici
 cov...@ccs.covici.com