<div class="gmail_quote"><div dir="ltr">On Thu, Jun 28, 2018, 18:37 MALET Jean-Luc <<a href="mailto:jeanluc.malet.snowsat@gmail.com">jeanluc.malet.snowsat@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi!<br>
<br>
I'm in charge of setting up an embedded solution based on debian, so on <br>
systemd, I'm more used to old init process, that was easy to tweak <br>
because based on script... but well... times seems now on systemd.<br>
<br>
I'm really puzzled because since the documentation seems to lack <br>
information, I have to find information on tutorials that focus only on <br>
late services..<br>
<br>
I found on one how to find the targets using "systemctl list-units <br>
--type=target" and some diagram explaining what target are suposed to be <br>
run in what order.... but well...<br>
<br>
my issue is that I've to run a script as early as possible, before <br>
mounts are done because lot of service will fail without , so I created <br>
a service<br></blockquote></div><div><br></div><div>Mainly I guess it's because systemd wants to *avoid* things like "before everything else" or "after everything else". (What if two units want to be first?) The idea is that dependencies should be a little more explicit if possible. For example, some of your services require /var/foo to be mounted? They can depend on "var-foo.mount" or at least "local-fs.target". And so on.</div><div><br></div><div>(Well, not to the extreme of course: even systemd has synchronization points like basic.target, local-fs.target, ...)</div><div><br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<br>
[Unit]<br>
Description=mount some file systems before anything and prepare the system<br>
Before=systemd-remount-fs.service<br>
<br>
[Service]<br>
Type=oneshot<br>
ExecStart=/etc/init.d/setup.sh start<br>
<br>
[Install]<br>
WantedBy=swap.target<br>
<br>
<br>
using journalctl I found that the first Reached point was the <br>
swap.target so it looked like a good WantedBy, but looking at the <br>
journalctl showed that the service was still not run in early systemd <br>
steps... so I added a Before rule using the "systemctl list-units <br>
--type=service" to guess what service where run on the system... and <br>
well... it's not working as expected... I still see my service run after <br>
some other services...<br></blockquote></div><div><br></div><div>basic.target or sysinit.target would be a better place, depending on what you do.</div><div><br></div><div>It might be a good idea to split the mega-script up if it tries to perform several distinct tasks, too.</div><div><br></div><div>In either case, add "DefaultDependencies=no" to your services, to opt out of all the hidden dependencies (which if I remember correctly are static, essentially After=basic.target).</div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><p dir="ltr">Mantas Mikulėnas</p>
</div>