1 |
Am 20.05.2014 12:29, schrieb covici@××××××××××.com: |
2 |
> Hi. I have a simple, static, ethernet network. However when booting |
3 |
> using systemd, a number of services which should start only after the |
4 |
> network is up, insist on starting in parallell and so fail for various |
5 |
> reasons. Here is my network service and my ntpdate service file, and I |
6 |
> would like to know how to get the ntpdate service file to wait till the |
7 |
> network is up before trying to start. |
8 |
> |
9 |
> Thanks in advance for any suggestions. |
10 |
> |
11 |
> Network service file: |
12 |
> [Unit] |
13 |
> Description=Network Connectivity for %i |
14 |
> Documentation= nam ip |
15 |
> Before=network.target |
16 |
> wants=network.target |
17 |
> BindsTo=sys-subsystem-net-devices-%i.device |
18 |
> After=sys-subsystem-net-devices-%i.device |
19 |
> [Service] |
20 |
> Type=oneshot |
21 |
> RemainAfterExit=yes |
22 |
> EnvironmentFile=/etc/conf.d/network@%i |
23 |
> ExecStart=/bin/ip link set dev %i up |
24 |
> ExecStart=/bin/ip addr add ${address}/${netmask} broadcast ${broadcast} dev %i |
25 |
> ExecStart=-/bin/bash -c "test -n ${gateway} && /bin/ip route add default via ${gateway}" |
26 |
> ExecStart=-/bin/bash -c "test -f /etc/conf.d/postup@%i.sh&&/bin/bash -c /etc/conf.d/postup@%i.sh" |
27 |
> ExecStop=/bin/ip addr flush dev %i |
28 |
> ExecStop=/bin/ip link set dev %i down |
29 |
> [Install] |
30 |
> WantedBy=multi-user.target |
31 |
> |
32 |
> and here is my ntpdate service file: |
33 |
> |
34 |
> [Unit] |
35 |
> Description=Set time via NTP using ntpdate |
36 |
> After=network.target nss-lookup.target |
37 |
> Before=time-sync.target |
38 |
> Wants=time-sync.target |
39 |
> |
40 |
> [Service] |
41 |
> Type=oneshot |
42 |
> EnvironmentFile=/etc/conf.d/ntp-client |
43 |
> ExecStart=/usr/sbin/ntpdate $NTPCLIENT_OPTS |
44 |
> RemainAfterExit=yes |
45 |
> |
46 |
> [Install] |
47 |
> WantedBy=multi-user.target |
48 |
> |
49 |
|
50 |
Hi there, |
51 |
|
52 |
setting "After=network.target" should just work (tm). I have a few |
53 |
custom service files which need a working network connection, and using |
54 |
this setting words for me. |
55 |
|
56 |
systemd-analyze plot > boot.svg also shows the these services only start |
57 |
after the network is up. |