1

I am converting a SysV init style file to Systemd Unit file and it's init section block looks like this:

### BEGIN INIT INFO
# Provides:          ifcheck 
# Required-Start:    $local_fs 
# Required-Stop:
# Should-Start:
# Should-Stop:
# Default-Start:     S
# Default-Stop:      
# Short-Description: Network interfaces check & replace
# Description:       Checks if the interfaces were corrupted or if the special section is missing. If so, a default version will be copied over.
### END INIT INFO

I know that run levels 0-6 correspond to various systemd targets:

╔══════════════════════╦═══════════════════╗
║ Run Level (SysVinit) ║  Systemd Target   ║
╠══════════════════════╬═══════════════════╣
│ Run level 0          │ poweroff.target   │
├──────────────────────┼───────────────────┤
│ Run level 1          │ rescue.target     │
├──────────────────────┼───────────────────┤
│ Run level 2          │ multi-user.target │
├──────────────────────┼───────────────────┤
│ Run level 3          │ multi-user.target │
├──────────────────────┼───────────────────┤
│ Run level 4          │ multi-user.target │
├──────────────────────┼───────────────────┤
│ Run level 5          │ graphical.target  │
├──────────────────────┼───────────────────┤
│ Run level 6          │ reboot.target     │
├──────────────────────┼───────────────────┤
│ Emergency            │ emergency.target  │
└──────────────────────┴───────────────────┘
(According to https://www.tecmint.com/change-runlevels-targets-in-systemd/ )

But I have never seen S as a run level before. I've seen some definitions that says it is for single-user while there are others that define it as a synonym for other run levels and still others don't have a conclusive defintion.

I know the version I am working with is most likely the Linux Standard Base specification because immediately after the init info block is the sourcing of the lsb init functions (Sourced via . /lib/lsb/init-functions). Also the system is running Debian 8 Jessie.

What target should I put in the equivalent systemd unit file for run level S?

2
  • Your first link says that it’s for single-user mode, not shutdown. Mar 31, 2020 at 14:11
  • Haha, you're right. I just saw "Runlevels 0, 6 and S are reserved for shutdown," and stopped reading there because my brain said "Oh, S for shutdown. Makes sense". I'll edit accordingly, thanks!
    – Wimateeka
    Mar 31, 2020 at 14:44

1 Answer 1

0

S has no direct correspondence in systemd. The systemd-sysv-generator program does not handle such van Smoorenburg rc scripts.

Debian used to have a patched version of that program that wrapped a rc script that used S inside a service unit with no default dependencies and that was wanted-by sysinit.target. This was imperfect, but then all of the operation of systemd-sysv-generator is imperfect, because there is no one-size-fits-all mechanistic way to translate van Smoorenburg rc scripts.

The Debian systemd people did away with the patch back in July 2016, when they believed that all of the van Smoorenburg rc scripts in Debian that used S had been superseded with proper service units. Yours appears to be home grown.

In this case, you are better off completely forgetting about the S run-level. My educated guess, based upon no more than the description, is that what you really should be making is a service unit that is:

DefaultDependencies=no
After=local-fs.target
Before=network-pre.target
Wants=network-pre.target
and that is Wanted-By something suitable, possibly basic.target.

Depending from what your service actually does, that ordering after local-fs.target may well be overkill. But that's something only you can determine.

Further reading

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .