[CentOS] CentOS 7, NSF, "feature"

Sylvain CANOINE sylvain.canoine at tv5monde.org
Wed Feb 3 19:19:48 UTC 2016


> De: "Ricardo J. Barberis" <ricardo at palmtx.com.ar>
> [Unit]
> After=network.target remote-fs.target nss-lookup.target network-online.target
> </code>
> 
> 
> The After line is the important one, I copied it from
> /usr/lib/systemd/system/nginx.service and added "network-online.target"
> at the end.
> 
> After making your changes, be sure to reenable the service so it takes your
> new unit, e.g.:
> 
> # systemctl reenable nginx.service
> 
> 
> It worked for me, maybe it works for you?
On my systems, I saw that network.target was not started, because no service required it ("After=foo" is totally useless if there isn't any "Require=foo" too... Mwokay, why not...). I just added a symlink to force network.target to start, and the ordering problem is solved :
/etc/systemd/system/multi-user.target.wants/network.target -> /usr/lib/systemd/system/network.target

That link avoids modifying the configuration of _all_ the services needing a fully working network (ssh, web, mail, snmp, and so on) with a crappy, but easy-to-deploy, one-liner like this (no, I'm not ashamed) :
# for fic in $(grep -rl "After=.*network.target" /lib/systemd/system | cut -d/ -f5 | grep -v "network-online.target") ; do [ ! -d "/etc/systemd/system/${fic}.d" ] && mkdir "/etc/systemd/system/${fic}.d" ; echo -e "[Unit]\nAfter=network-online.target" > "/etc/systemd/system/${fic}.d/local-network-online.conf" ; done && systemctl daemon-reload

By the way, congratulations to the genius who decided to name one of the files "-.slice"... Yes, a filename beginning by a hyphen. I suppose anybody here understands why it's probably one of the worst ideas he never had.

Sylvain.
Pensez ENVIRONNEMENT : n'imprimer que si ncessaire




More information about the CentOS mailing list