Insert a script into boot order at a specific place

Martin Pitt mpitt at debian.org
Sat Apr 11 13:59:52 BST 2015


Hey Christoph,

Christoph Pleger [2015-03-09 14:48 +0100]:
> for many years and up to Debian 7, I have been using a script to configure
> some things while booting the system, i.e. I had a link in /etc/rcS.d/
> which was executed directly after mounting local and remote filesystems
> and before doing anything else (in my Debian 7, this is after
> mountnfs-bootclean.sh and before kbd). This order is necessary, otherwise
> the script is not able to configure the system correcly.

Note that with systemd and even with modern SysV init with insserv
you can't (in general) pin-point the exact order of a script simply
because they just form a tree, not a list.

> After switching from SYS V boot to systemd boot, how can I achieve a
> similar  order, so that only very basic tasks (bringing network up,
> mounting filesystems) are performed before my script runs and all the
> remaining tasks are performed after my script was finished? Without me
> having to know too much about which tasks have to be performed before and
> which ones afterwards, so that I can define only a few dependencies,
> similar to what I used in my LSB init script, which only defines:
> 
> Required-Start:    nfs-common $remote_fs
> 
> and
> 
> 
> X-Start-Before:    console-screen kbd

Note that init.d scripts continue to work as under sysvinit, so you
could just keep it as it is. If you want to provide a native systemd
unit, something like this sohuld be fairly equivalent:

  # equivalent of "run during early boot in rcS"
  DefaultDependencies=no
  After=remote-fs.target
  # run before most other services, i. e. still during early boot
  Before=basic.target

You could also directly translate your original

  Before=console-screen.service kbd.service

but I suppose you don't need to be that specific?

Martin
-- 
Martin Pitt                        | http://www.piware.de
Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)



More information about the Pkg-systemd-maintainers mailing list