[systemd-devel] Starting a script early in boot
Lennart Poettering
lennart at poettering.net
Tue Sep 7 04:54:27 PDT 2010
On Mon, 06.09.10 19:44, Daniel Drake (dsd at laptop.org) wrote:
heya,
> After reading the systemd man pages, I believe I want it to start
> after basic.target has fully started up, but before anything in
> multi-user.target starts. And I want everything in multi-user.target
> to await the completion of my script before starting.
You probably need to stick this after
local-fst.target+sysinit.target and before base.target.
> So I came up with the olpc-configure.service:
>
> [Unit]
> Description=olpc-configure
> After=basic.target
> Before=multi-user.target
>
> [Service]
> Type=oneshot
> ExecStart=/usr/bin/olpc-configure
>
> [Install]
> WantedBy=multi-user.target
>
>
> And it doesn't work :(
> Through adding some logging, I can see that NetworkManager, X, HAL,
> ... are all running during the execution of olpc-configure (I was
> hoping they would wait).
systemd actually tries to start things as early as possible, so the unit
file would start it right after basic.target is done but make sure not to
activate multi-user.target before it finished. That means it is run
between basic.target and multi-user.target, and hence in parallel to all
other normal services.
All units by default are actually ordered so that they are run after
"basic.target". If you have a special unit (and you do) that needs to be
run very early at boot you must disable those implicit default
dependencies by setting "DefaultDependencies=no" and adding the
right ones manually. So you probably want something like this:
<snip>
[Unit]
Description=OLPC Configuration
DefaultDependencies=no
After=sysinit.target local-fs.target
Before=base.target
[Service]
Type=oneshot
ExecStart=/usr/bin/olpc-configure
[Install]
WantedBy=base.target
</snip>
Lennart
--
Lennart Poettering - Red Hat, Inc.
More information about the systemd-devel
mailing list