I am looking for a way to instruct systemd to recalculate service dependencies while the system is booting. Specifically, I need one service to be able to enable another service, and have the second service start up later in the same boot sequence. This is part of my automatic deployment process; very early in the boot process, the first time the system starts up, it automatically configures itself. One of the steps that it may need to take is enabling other services. Unfortunately, any changes it makes at that step do not seem to take effect until the following reboot. Rebooting the machine after initial deployment is not an option.
Here's a generalized idea of what I'm trying to achieve
[Unit] Description=Enable MyService DefaultDependencies=no After=sysinit.target Before=basic.target [Service] Type=oneshot ExecStart=/bin/systemctl enable myservice.service ExecStartPost=/bin/systemctl disable firstboot.service [Install] RequiredBy=basic.target
[Unit] Description=MyService [Service] Type=simple ExecStart=/usr/local/bin/myservice [Install] WantedBy=multi-user.target
Unfortunately, this doesn't work as I expected; the service is enabled, but is not started before
$ systemctl status myservice myservice.service - MyService Loaded: loaded (/etc/systemd/system/myservice.service; enabled) Active: inactive (dead)
I can force it to start with
systemctl isolate multi-user.target or by rebooting the machine.
I have tried adding
systemctl daemon-reload and/or
systemctl daemon-reexec to
firstboot.service, but neither seem to have any effect.
Is there any way I can tell systemd to recalculate the boot path and include the changes that were made while it was still booting? Or will I need to do something later in the boot process to force my service to start?