Gentoo Archives: gentoo-user

From: covici@××××××××××.com
To: gentoo-user@l.g.o
Subject: [gentoo-user] systemd how can I get a service to start after network is up
Date: Tue, 20 May 2014 10:29:16
Message-Id: 10251.1400581747@ccs.covici.com
1 Hi. I have a simple, static, ethernet network. However when booting
2 using systemd, a number of services which should start only after the
3 network is up, insist on starting in parallell and so fail for various
4 reasons. Here is my network service and my ntpdate service file, and I
5 would like to know how to get the ntpdate service file to wait till the
6 network is up before trying to start.
7
8 Thanks in advance for any suggestions.
9
10 Network service file:
11 [Unit]
12 Description=Network Connectivity for %i
13 Documentation= nam ip
14 Before=network.target
15 wants=network.target
16 BindsTo=sys-subsystem-net-devices-%i.device
17 After=sys-subsystem-net-devices-%i.device
18 [Service]
19 Type=oneshot
20 RemainAfterExit=yes
21 EnvironmentFile=/etc/conf.d/network@%i
22 ExecStart=/bin/ip link set dev %i up
23 ExecStart=/bin/ip addr add ${address}/${netmask} broadcast ${broadcast} dev %i
24 ExecStart=-/bin/bash -c "test -n ${gateway} && /bin/ip route add default via ${gateway}"
25 ExecStart=-/bin/bash -c "test -f /etc/conf.d/postup@%i.sh&&/bin/bash -c /etc/conf.d/postup@%i.sh"
26 ExecStop=/bin/ip addr flush dev %i
27 ExecStop=/bin/ip link set dev %i down
28 [Install]
29 WantedBy=multi-user.target
30
31 and here is my ntpdate service file:
32
33 [Unit]
34 Description=Set time via NTP using ntpdate
35 After=network.target nss-lookup.target
36 Before=time-sync.target
37 Wants=time-sync.target
38
39 [Service]
40 Type=oneshot
41 EnvironmentFile=/etc/conf.d/ntp-client
42 ExecStart=/usr/sbin/ntpdate $NTPCLIENT_OPTS
43 RemainAfterExit=yes
44
45 [Install]
46 WantedBy=multi-user.target
47
48 --
49 Your life is like a penny. You're going to lose it. The question is:
50 How do
51 you spend it?
52
53 John Covici
54 covici@××××××××××.com

Replies

Subject Author
Re: [gentoo-user] systemd how can I get a service to start after network is up Michael Hampicke <mh@××××.biz>