What is the default path that systemd uses to locate locate System V scripts?How does systemd use /etc/init.d...
Succinct and gender-neutral Russian word for "writer"
Is this state of Earth possible, after humans left for a million years?
Is it a good idea to copy a trader when investing?
Can 'sudo apt-get remove [write]' destroy my Ubuntu?
Cryptography and elliptic curves
A Cunning Riley Riddle
Pre-1993 comic in which Wolverine's claws were turned to rubber?
How to slow yourself down (for playing nice with others)
Watching the game, having a puzzle
spatiotemporal regression
Intersecting with the x-axis / intersecting the x-axis
Is there a need for better software for writers?
Company stopped paying my salary. What are my options?
Why are low spin tetrahedral complexes so rare?
Why do the non-leaf Nodes of Merkle tree need to be hashed?
Is a vertical stabiliser needed for straight line flight in a glider?
Names of the Six Tastes
Should I pay on student loans in deferment or continue to snowball other debts?
What can cause an unfrozen indoor copper drain pipe to crack?
Why does the Earth follow an elliptical trajectory rather than a parabolic one?
My perfect evil overlord plan... or is it?
What is the name of meteoroids which hit Moon, Mars, or pretty much anything that isn’t the Earth?
Why was the ancient one so hesitant to teach Dr Strange the art of sorcery
Is ‘despite that’ right?
What is the default path that systemd uses to locate locate System V scripts?
How does systemd use /etc/init.d scripts?Does systemd still know about runlevels?initctl: Unable to connect to Upstartsystemctl list all possible (including disabled) services/etc/init.d and /etc/rcX.d/: how do they work with systemdSystemd and SysVinit compatibility modeHow does systemd use /etc/init.d scripts?Do I need set ulimit for system services, such as nginx.service(systemd)/nginx(sysv)?Why does using the service command work on a systemd distro?What are the variables $remote_fs and $syslog on SysVinit LSB header?In systemd, what starts units generated by generator?Configuring Debian's opendkim package's init script parameters with both init.d and systemctl scripts being presentHow systemd Type option affects starting other units?Create dependency in SysV file to a systemd servicesystemd doesn't recognize init.d status
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
Is /etc/init.d the default search path that the systemd generator uses to convert native SysV script to unit files, and falls back to /etc/rc?.d or vice versa?
From this answer by @JdeBP:
This program is a generator, a type of ancillary utility whose job is to create service unit files on the fly, in a tmpfs where three more of those nine directories (which are intended to be used only by generators) are located.
systemd-sysv-generatorgenerates the service units that run the System Vrcscripts from/etc/init.d, if it doesn't find a native systemd service unit by that name already existing in the other six locations.
But, How Linux Works book mentions something different:
- First, systemd activates
runlevel<N>.target, where N is the runlevel.
- For each symbolic link in
/etc/rc<N>.d, systemd identifies the script in /etc/init.d.
- systemd associates the script name with a service unit (for example, /etc/init.d/foo would be foo.service).
- systemd activates the service unit and runs the script with either a start or stop argument, based on its name in
rc<N>.d.
- systemd attempts to associate any processes from the script with the service unit.
As far as I can tell, the procedure goes in the following way: systemd finds SysV scripts in /etc/init.d and depending on the runlevel, systemd decides to start or stop the scripts according to the symlink name (K* or S*) from /etc/rc?.d. This makes sense, because once the SysV script is converted into a native systemd unit file, the decision to start or to stop the process has to be obtained from /etc/rc?.d. For example, I'm running Ubuntu 17.04:
$ ls -l /etc/rc5.d
lrwxrwxrwx 1 root root 15 Aug 4 00:10 S01acpid -> ../init.d/acpid
lrwxrwxrwx 1 root root 17 Aug 4 00:10 S01anacron -> ../init.d/anacron
lrwxrwxrwx 1 root root 16 Aug 4 00:10 S01apport -> ../init.d/apport
lrwxrwxrwx 1 root root 22 Aug 4 00:10 S01avahi-daemon -> ../init.d/avahi-daemon
...many more...
I can see that all of the symlinks to the scripts have the same execution order 01, and this is done intentionally so to exploit parallelism in systemd, so systemd-sysv-generator uses /etc/rc?.d to also determine the order of the dependencies (e.g, Before, After).
Since the LSB header within scripts determine the runlevel in which scripts are run, I'm more to likely lean towards the idea that systemd-sysv-generator defaults to /etc/init.d to decide which scripts to start in which runlevel instead of /etc/rc?.d, except if that can't be determined from the LSB header within the script. Are my assumptions right?
systemd-sysv-generator(8)
LSB headers[2]in SysV init scripts are interpreted, and the ordering specified in the header is turned into dependencies between the
generated unit and other units. The LSB facilities"$remote_fs","$network","$named","$portmap","$time"are supported and will be turned into dependencies on specific native systemd targets.
But the man page doesn't mention anything related to the case where there's no LSB header. Pretty much over complicated :.
systemd init sysv
add a comment |
Is /etc/init.d the default search path that the systemd generator uses to convert native SysV script to unit files, and falls back to /etc/rc?.d or vice versa?
From this answer by @JdeBP:
This program is a generator, a type of ancillary utility whose job is to create service unit files on the fly, in a tmpfs where three more of those nine directories (which are intended to be used only by generators) are located.
systemd-sysv-generatorgenerates the service units that run the System Vrcscripts from/etc/init.d, if it doesn't find a native systemd service unit by that name already existing in the other six locations.
But, How Linux Works book mentions something different:
- First, systemd activates
runlevel<N>.target, where N is the runlevel.
- For each symbolic link in
/etc/rc<N>.d, systemd identifies the script in /etc/init.d.
- systemd associates the script name with a service unit (for example, /etc/init.d/foo would be foo.service).
- systemd activates the service unit and runs the script with either a start or stop argument, based on its name in
rc<N>.d.
- systemd attempts to associate any processes from the script with the service unit.
As far as I can tell, the procedure goes in the following way: systemd finds SysV scripts in /etc/init.d and depending on the runlevel, systemd decides to start or stop the scripts according to the symlink name (K* or S*) from /etc/rc?.d. This makes sense, because once the SysV script is converted into a native systemd unit file, the decision to start or to stop the process has to be obtained from /etc/rc?.d. For example, I'm running Ubuntu 17.04:
$ ls -l /etc/rc5.d
lrwxrwxrwx 1 root root 15 Aug 4 00:10 S01acpid -> ../init.d/acpid
lrwxrwxrwx 1 root root 17 Aug 4 00:10 S01anacron -> ../init.d/anacron
lrwxrwxrwx 1 root root 16 Aug 4 00:10 S01apport -> ../init.d/apport
lrwxrwxrwx 1 root root 22 Aug 4 00:10 S01avahi-daemon -> ../init.d/avahi-daemon
...many more...
I can see that all of the symlinks to the scripts have the same execution order 01, and this is done intentionally so to exploit parallelism in systemd, so systemd-sysv-generator uses /etc/rc?.d to also determine the order of the dependencies (e.g, Before, After).
Since the LSB header within scripts determine the runlevel in which scripts are run, I'm more to likely lean towards the idea that systemd-sysv-generator defaults to /etc/init.d to decide which scripts to start in which runlevel instead of /etc/rc?.d, except if that can't be determined from the LSB header within the script. Are my assumptions right?
systemd-sysv-generator(8)
LSB headers[2]in SysV init scripts are interpreted, and the ordering specified in the header is turned into dependencies between the
generated unit and other units. The LSB facilities"$remote_fs","$network","$named","$portmap","$time"are supported and will be turned into dependencies on specific native systemd targets.
But the man page doesn't mention anything related to the case where there's no LSB header. Pretty much over complicated :.
systemd init sysv
Possible duplicate of How does systemd use /etc/init.d scripts?
– thecarpy
Sep 24 '17 at 19:55
@thecarpy it's certainly related - and the OP has even referenced this same question/answer in their own question (above). But they're not duplicates; this one's asking about the search path, and that's not defined in any of the answers of your proposed duplicate
– roaima
Sep 24 '17 at 20:20
1
§6.4.8 of M. Ward's book is in need of some heavy revision for the 3rd edition. There are a lot of errors in there, starting with the incorrect statement that systemd activates any runlevel targets. systemd does not work that way.
– JdeBP
Sep 25 '17 at 4:52
@JdeBP I wonder why systemd is one of the most misunderstood inits. In the answer you've provided in your comment, you state thatsystemd-sysv-generator: "merges the/etc/rc[234].ddirectories into just the oneWanted-Byrelationship tomulti-user.targetin generated service units." What about the LSB headers? AFAIK, the LSB headers used to determine the order and the dependencies of the scripts in/etc/init.d. Without LSB, the fallback option isrc?.dI don't really quite understand the whole process involved here. Red Hat guys give us magic but don't tell us how it works!
– direprobs
Sep 25 '17 at 8:01
add a comment |
Is /etc/init.d the default search path that the systemd generator uses to convert native SysV script to unit files, and falls back to /etc/rc?.d or vice versa?
From this answer by @JdeBP:
This program is a generator, a type of ancillary utility whose job is to create service unit files on the fly, in a tmpfs where three more of those nine directories (which are intended to be used only by generators) are located.
systemd-sysv-generatorgenerates the service units that run the System Vrcscripts from/etc/init.d, if it doesn't find a native systemd service unit by that name already existing in the other six locations.
But, How Linux Works book mentions something different:
- First, systemd activates
runlevel<N>.target, where N is the runlevel.
- For each symbolic link in
/etc/rc<N>.d, systemd identifies the script in /etc/init.d.
- systemd associates the script name with a service unit (for example, /etc/init.d/foo would be foo.service).
- systemd activates the service unit and runs the script with either a start or stop argument, based on its name in
rc<N>.d.
- systemd attempts to associate any processes from the script with the service unit.
As far as I can tell, the procedure goes in the following way: systemd finds SysV scripts in /etc/init.d and depending on the runlevel, systemd decides to start or stop the scripts according to the symlink name (K* or S*) from /etc/rc?.d. This makes sense, because once the SysV script is converted into a native systemd unit file, the decision to start or to stop the process has to be obtained from /etc/rc?.d. For example, I'm running Ubuntu 17.04:
$ ls -l /etc/rc5.d
lrwxrwxrwx 1 root root 15 Aug 4 00:10 S01acpid -> ../init.d/acpid
lrwxrwxrwx 1 root root 17 Aug 4 00:10 S01anacron -> ../init.d/anacron
lrwxrwxrwx 1 root root 16 Aug 4 00:10 S01apport -> ../init.d/apport
lrwxrwxrwx 1 root root 22 Aug 4 00:10 S01avahi-daemon -> ../init.d/avahi-daemon
...many more...
I can see that all of the symlinks to the scripts have the same execution order 01, and this is done intentionally so to exploit parallelism in systemd, so systemd-sysv-generator uses /etc/rc?.d to also determine the order of the dependencies (e.g, Before, After).
Since the LSB header within scripts determine the runlevel in which scripts are run, I'm more to likely lean towards the idea that systemd-sysv-generator defaults to /etc/init.d to decide which scripts to start in which runlevel instead of /etc/rc?.d, except if that can't be determined from the LSB header within the script. Are my assumptions right?
systemd-sysv-generator(8)
LSB headers[2]in SysV init scripts are interpreted, and the ordering specified in the header is turned into dependencies between the
generated unit and other units. The LSB facilities"$remote_fs","$network","$named","$portmap","$time"are supported and will be turned into dependencies on specific native systemd targets.
But the man page doesn't mention anything related to the case where there's no LSB header. Pretty much over complicated :.
systemd init sysv
Is /etc/init.d the default search path that the systemd generator uses to convert native SysV script to unit files, and falls back to /etc/rc?.d or vice versa?
From this answer by @JdeBP:
This program is a generator, a type of ancillary utility whose job is to create service unit files on the fly, in a tmpfs where three more of those nine directories (which are intended to be used only by generators) are located.
systemd-sysv-generatorgenerates the service units that run the System Vrcscripts from/etc/init.d, if it doesn't find a native systemd service unit by that name already existing in the other six locations.
But, How Linux Works book mentions something different:
- First, systemd activates
runlevel<N>.target, where N is the runlevel.
- For each symbolic link in
/etc/rc<N>.d, systemd identifies the script in /etc/init.d.
- systemd associates the script name with a service unit (for example, /etc/init.d/foo would be foo.service).
- systemd activates the service unit and runs the script with either a start or stop argument, based on its name in
rc<N>.d.
- systemd attempts to associate any processes from the script with the service unit.
As far as I can tell, the procedure goes in the following way: systemd finds SysV scripts in /etc/init.d and depending on the runlevel, systemd decides to start or stop the scripts according to the symlink name (K* or S*) from /etc/rc?.d. This makes sense, because once the SysV script is converted into a native systemd unit file, the decision to start or to stop the process has to be obtained from /etc/rc?.d. For example, I'm running Ubuntu 17.04:
$ ls -l /etc/rc5.d
lrwxrwxrwx 1 root root 15 Aug 4 00:10 S01acpid -> ../init.d/acpid
lrwxrwxrwx 1 root root 17 Aug 4 00:10 S01anacron -> ../init.d/anacron
lrwxrwxrwx 1 root root 16 Aug 4 00:10 S01apport -> ../init.d/apport
lrwxrwxrwx 1 root root 22 Aug 4 00:10 S01avahi-daemon -> ../init.d/avahi-daemon
...many more...
I can see that all of the symlinks to the scripts have the same execution order 01, and this is done intentionally so to exploit parallelism in systemd, so systemd-sysv-generator uses /etc/rc?.d to also determine the order of the dependencies (e.g, Before, After).
Since the LSB header within scripts determine the runlevel in which scripts are run, I'm more to likely lean towards the idea that systemd-sysv-generator defaults to /etc/init.d to decide which scripts to start in which runlevel instead of /etc/rc?.d, except if that can't be determined from the LSB header within the script. Are my assumptions right?
systemd-sysv-generator(8)
LSB headers[2]in SysV init scripts are interpreted, and the ordering specified in the header is turned into dependencies between the
generated unit and other units. The LSB facilities"$remote_fs","$network","$named","$portmap","$time"are supported and will be turned into dependencies on specific native systemd targets.
But the man page doesn't mention anything related to the case where there's no LSB header. Pretty much over complicated :.
systemd init sysv
systemd init sysv
edited Sep 24 '17 at 20:09
direprobs
asked Sep 24 '17 at 19:45
direprobsdireprobs
411320
411320
Possible duplicate of How does systemd use /etc/init.d scripts?
– thecarpy
Sep 24 '17 at 19:55
@thecarpy it's certainly related - and the OP has even referenced this same question/answer in their own question (above). But they're not duplicates; this one's asking about the search path, and that's not defined in any of the answers of your proposed duplicate
– roaima
Sep 24 '17 at 20:20
1
§6.4.8 of M. Ward's book is in need of some heavy revision for the 3rd edition. There are a lot of errors in there, starting with the incorrect statement that systemd activates any runlevel targets. systemd does not work that way.
– JdeBP
Sep 25 '17 at 4:52
@JdeBP I wonder why systemd is one of the most misunderstood inits. In the answer you've provided in your comment, you state thatsystemd-sysv-generator: "merges the/etc/rc[234].ddirectories into just the oneWanted-Byrelationship tomulti-user.targetin generated service units." What about the LSB headers? AFAIK, the LSB headers used to determine the order and the dependencies of the scripts in/etc/init.d. Without LSB, the fallback option isrc?.dI don't really quite understand the whole process involved here. Red Hat guys give us magic but don't tell us how it works!
– direprobs
Sep 25 '17 at 8:01
add a comment |
Possible duplicate of How does systemd use /etc/init.d scripts?
– thecarpy
Sep 24 '17 at 19:55
@thecarpy it's certainly related - and the OP has even referenced this same question/answer in their own question (above). But they're not duplicates; this one's asking about the search path, and that's not defined in any of the answers of your proposed duplicate
– roaima
Sep 24 '17 at 20:20
1
§6.4.8 of M. Ward's book is in need of some heavy revision for the 3rd edition. There are a lot of errors in there, starting with the incorrect statement that systemd activates any runlevel targets. systemd does not work that way.
– JdeBP
Sep 25 '17 at 4:52
@JdeBP I wonder why systemd is one of the most misunderstood inits. In the answer you've provided in your comment, you state thatsystemd-sysv-generator: "merges the/etc/rc[234].ddirectories into just the oneWanted-Byrelationship tomulti-user.targetin generated service units." What about the LSB headers? AFAIK, the LSB headers used to determine the order and the dependencies of the scripts in/etc/init.d. Without LSB, the fallback option isrc?.dI don't really quite understand the whole process involved here. Red Hat guys give us magic but don't tell us how it works!
– direprobs
Sep 25 '17 at 8:01
Possible duplicate of How does systemd use /etc/init.d scripts?
– thecarpy
Sep 24 '17 at 19:55
Possible duplicate of How does systemd use /etc/init.d scripts?
– thecarpy
Sep 24 '17 at 19:55
@thecarpy it's certainly related - and the OP has even referenced this same question/answer in their own question (above). But they're not duplicates; this one's asking about the search path, and that's not defined in any of the answers of your proposed duplicate
– roaima
Sep 24 '17 at 20:20
@thecarpy it's certainly related - and the OP has even referenced this same question/answer in their own question (above). But they're not duplicates; this one's asking about the search path, and that's not defined in any of the answers of your proposed duplicate
– roaima
Sep 24 '17 at 20:20
1
1
§6.4.8 of M. Ward's book is in need of some heavy revision for the 3rd edition. There are a lot of errors in there, starting with the incorrect statement that systemd activates any runlevel targets. systemd does not work that way.
– JdeBP
Sep 25 '17 at 4:52
§6.4.8 of M. Ward's book is in need of some heavy revision for the 3rd edition. There are a lot of errors in there, starting with the incorrect statement that systemd activates any runlevel targets. systemd does not work that way.
– JdeBP
Sep 25 '17 at 4:52
@JdeBP I wonder why systemd is one of the most misunderstood inits. In the answer you've provided in your comment, you state that
systemd-sysv-generator: "merges the /etc/rc[234].d directories into just the one Wanted-By relationship to multi-user.target in generated service units." What about the LSB headers? AFAIK, the LSB headers used to determine the order and the dependencies of the scripts in /etc/init.d. Without LSB, the fallback option is rc?.d I don't really quite understand the whole process involved here. Red Hat guys give us magic but don't tell us how it works!– direprobs
Sep 25 '17 at 8:01
@JdeBP I wonder why systemd is one of the most misunderstood inits. In the answer you've provided in your comment, you state that
systemd-sysv-generator: "merges the /etc/rc[234].d directories into just the one Wanted-By relationship to multi-user.target in generated service units." What about the LSB headers? AFAIK, the LSB headers used to determine the order and the dependencies of the scripts in /etc/init.d. Without LSB, the fallback option is rc?.d I don't really quite understand the whole process involved here. Red Hat guys give us magic but don't tell us how it works!– direprobs
Sep 25 '17 at 8:01
add a comment |
2 Answers
2
active
oldest
votes
I marked your question as a duplicate.
Read JdeBP great answer here: How does systemd use /etc/init.d scripts?
Received wisdom is that the System V
rcscripts must have an LSB header, and are run in parallel without honouring the priorities imposed by the/etc/rc?.d/system. This is incorrect on all points.
In fact, they don't need to have an LSB header, and if they do not systemd-sysv-generator can recognize the more limited old RedHat comment headers (
description:,pidfile:, and so forth). Moreover, in the absence of an LSB header it will fall back to the contents of the/etc/rc?.dsymbolic link farms, reading the priorities encoded into the link names and constructing a before/after ordering from them, serializing the services. Not only are LSB headers not a requirement, and not only do they themselves encode before/after orderings that serialize things to an extent, the fallback behaviour in their complete absence is actually significantly non-parallelized operation.
The reason that
/etc/rc3.ddidn't appear to matter is that you probably had that script enabled via another/etc/rc?.d/directory.systemd-sysv-generatortranslates being listed in any of/etc/rc2.d/,/etc/rc3.d/, and/etc/rc4.d/into a nativeWanted-Byrelationship to systemd'smulti-user.target. Run levels are "obsolete" in the systemd world, and you can forget about them.
The question of what the search path is, is in fact actually addressed by what you quoted in your question:
systemd-sysv-generatorgenerates the service units that run the System Vrcscripts from/etc/init.d, if it doesn't find a native systemd service unit by that name already existing in the other six locations.
In more detail:
- For the scripts themselves:
systemd-sysv-generatorlooks for an environment variable namedSYSTEMD_SYSVINIT_PATH.
- If it exists, it is expected to be a conventional colon-separated search path of directories that
systemd-sysv-generatorscans one by one. - If it does not exist, or if it has an empty value,
systemd-sysv-generatorfalls back upon a compiled-in default, which in vanilla systemd is the single directory/etc/init.d/.
- If it exists, it is expected to be a conventional colon-separated search path of directories that
- Each directory is scanned for regular files that have the owner execute permission bit set on, with earlier directories in the path overriding later ones (a mechanism not really exercised in the default case of just the one directory in the search path) and the existence of service units with the same names inhibiting the generation of these nonce ones.
- For the "symbolic link farms":
- There is a similar environment variable named
SYSTEMD_SYSVRCND_PATH.
- If it exists, it is expected to be a conventional colon-separated search path of directories that
systemd-sysv-generatorscans one by one. - If it does not exist, or if it has an empty value,
systemd-sysv-generatorfalls back upon a compiled-in default, which in vanilla systemd is the single directory/etc/rc.d/.
- If it exists, it is expected to be a conventional colon-separated search path of directories that
- Each directory is scanned for subdirectories named
rc[2345].d, which are in turn scanned for directory entries that begin withSand two decimal digits and that are at least 4 characters long. The directory entries are not dereferenced.
- There is a similar environment variable named
Notice that systemd-sysv-generator …
- … does not look at the
K*stuff; - … does not check that the symbolic link farms are actually filled with symbolic links (They could be character special files or FIFOs for all that it cares, as it only looks at the names.); and
- … does not process the runlevel information from LSB comments (i.e. the
Default-Start:andDefault-Stop:comments).
Remember, in respect of the third point, that in vanilla van Smoorenburg rc the runlevel information from LSB comments does not directly control bootstrap/shutdown behaviour. That's the remit of the symbolic link farm directories. Describing van Smoorenburg rc in systemd terminology: the symbolic link farms are the service enable controls, that determine what services are automatically started at bootstrap; whereas the Default-Start: and Default-Stop: comments are (very approximately) service preset controls, that are turned into the enable controls.
This is the question I linked in my question though. There's contradiction between the book I'm reading and the answer. I can't assert which one is right!
– direprobs
Sep 24 '17 at 20:08
@direprobs Part 5 in your quote is nonsense. Systemd does not attempt to adopt processes started by some other system. I think you can write off the book for reliable technical details, after all it does not mention LSB headers.
– sourcejedi
Sep 24 '17 at 21:21
add a comment |
I just did some trial runs on this to find out more, kind of a follow on to thecarpy's answer.
From what I can tell systemd-sysv-generator does the following: if there's a script in /etc/init.d it checks /etc/rc?.d/ and sees if it's part of "any runlevel." If it is, it adds it to that runlevel in the systemd hierarchy. It also gets Description information from the LSB headers in the init.d file. It also adds any hierarchy information from LSB
# Required-Start: bar
type line.
Things get weirder from there. If you run systemctl enable my_service it basically "farms out" to chkconfig to adjust the /etc/rc?.d directories, then runs systemctl daemon-reload after that to soak up the new information. However it runs it like /sbin/chkconfig my_service on (note that trailing on) which instructs it to turn it on for runlevels 2-5, and ignore the levels specified anywhere in the init.d file. However if you run chkconfig manually like chkconfig --add my_service then it respects the levels specified in the script.
Also weird: if there is no runlevel specified in the init.d file and it isn't yet symlinked in any /etc/rc?.d folder, then the systemd-sysv-generatoreems to assume you want it to be started in runlevel 4 and 5.
Plus, even if your default starting runlevel is 3, that's the same as 4 and 5. So basically it seems to assume you want to start it, no matter what, despite it not being symlinked in any rc?.d dirs.
Also if the init.d script does specify runlevels but is absent from all rc?.d dirs (a la chkconfig --del my_service or its equivalent systemctl disable my_service, or if chkconfig was never run on it) then the systemd-sysv-generator does not enable it, so it is left "disabled" And then it seems to not show up in the lists if you run systemctl list-units --all etc.
Also of note, there are two ways to specify the runlevel, both chkconfig and systemctl seem to "prefer LSB over the "old style"
chkconfig man page says:
Each service which should be manageable by chkconfig needs two or more commented lines added to its init.d script.
...
# chkconfig: 2345 20 80
# description: Saves and restores system entropy pool for
# higher quality random number generation.
chkconfig also supports LSB-style init stanzas, and will apply them in preference to "chkconfig:" lines where available. A LSB stanza looks like:
### BEGIN INIT INFO
# Provides: foo
# Required-Start: bar
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: Foo init script
### END INIT INFO
So in general that book doesn't seem quite in a right oder. The systemd-sysv-generator runs very early on in the boot phase, and sets up services (as specified above) and also enables them in the "run level equivalent" target if it deems they should be autorun. Then the boot proceeds, and starts up all services in the normal systemd order.
So, to answer the question, it uses a combination of etc/init.d and/etc/rc?.deach timesystemd` loads or reloads. In whacky ways.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f394187%2fwhat-is-the-default-path-that-systemd-uses-to-locate-locate-system-v-scripts%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
I marked your question as a duplicate.
Read JdeBP great answer here: How does systemd use /etc/init.d scripts?
Received wisdom is that the System V
rcscripts must have an LSB header, and are run in parallel without honouring the priorities imposed by the/etc/rc?.d/system. This is incorrect on all points.
In fact, they don't need to have an LSB header, and if they do not systemd-sysv-generator can recognize the more limited old RedHat comment headers (
description:,pidfile:, and so forth). Moreover, in the absence of an LSB header it will fall back to the contents of the/etc/rc?.dsymbolic link farms, reading the priorities encoded into the link names and constructing a before/after ordering from them, serializing the services. Not only are LSB headers not a requirement, and not only do they themselves encode before/after orderings that serialize things to an extent, the fallback behaviour in their complete absence is actually significantly non-parallelized operation.
The reason that
/etc/rc3.ddidn't appear to matter is that you probably had that script enabled via another/etc/rc?.d/directory.systemd-sysv-generatortranslates being listed in any of/etc/rc2.d/,/etc/rc3.d/, and/etc/rc4.d/into a nativeWanted-Byrelationship to systemd'smulti-user.target. Run levels are "obsolete" in the systemd world, and you can forget about them.
The question of what the search path is, is in fact actually addressed by what you quoted in your question:
systemd-sysv-generatorgenerates the service units that run the System Vrcscripts from/etc/init.d, if it doesn't find a native systemd service unit by that name already existing in the other six locations.
In more detail:
- For the scripts themselves:
systemd-sysv-generatorlooks for an environment variable namedSYSTEMD_SYSVINIT_PATH.
- If it exists, it is expected to be a conventional colon-separated search path of directories that
systemd-sysv-generatorscans one by one. - If it does not exist, or if it has an empty value,
systemd-sysv-generatorfalls back upon a compiled-in default, which in vanilla systemd is the single directory/etc/init.d/.
- If it exists, it is expected to be a conventional colon-separated search path of directories that
- Each directory is scanned for regular files that have the owner execute permission bit set on, with earlier directories in the path overriding later ones (a mechanism not really exercised in the default case of just the one directory in the search path) and the existence of service units with the same names inhibiting the generation of these nonce ones.
- For the "symbolic link farms":
- There is a similar environment variable named
SYSTEMD_SYSVRCND_PATH.
- If it exists, it is expected to be a conventional colon-separated search path of directories that
systemd-sysv-generatorscans one by one. - If it does not exist, or if it has an empty value,
systemd-sysv-generatorfalls back upon a compiled-in default, which in vanilla systemd is the single directory/etc/rc.d/.
- If it exists, it is expected to be a conventional colon-separated search path of directories that
- Each directory is scanned for subdirectories named
rc[2345].d, which are in turn scanned for directory entries that begin withSand two decimal digits and that are at least 4 characters long. The directory entries are not dereferenced.
- There is a similar environment variable named
Notice that systemd-sysv-generator …
- … does not look at the
K*stuff; - … does not check that the symbolic link farms are actually filled with symbolic links (They could be character special files or FIFOs for all that it cares, as it only looks at the names.); and
- … does not process the runlevel information from LSB comments (i.e. the
Default-Start:andDefault-Stop:comments).
Remember, in respect of the third point, that in vanilla van Smoorenburg rc the runlevel information from LSB comments does not directly control bootstrap/shutdown behaviour. That's the remit of the symbolic link farm directories. Describing van Smoorenburg rc in systemd terminology: the symbolic link farms are the service enable controls, that determine what services are automatically started at bootstrap; whereas the Default-Start: and Default-Stop: comments are (very approximately) service preset controls, that are turned into the enable controls.
This is the question I linked in my question though. There's contradiction between the book I'm reading and the answer. I can't assert which one is right!
– direprobs
Sep 24 '17 at 20:08
@direprobs Part 5 in your quote is nonsense. Systemd does not attempt to adopt processes started by some other system. I think you can write off the book for reliable technical details, after all it does not mention LSB headers.
– sourcejedi
Sep 24 '17 at 21:21
add a comment |
I marked your question as a duplicate.
Read JdeBP great answer here: How does systemd use /etc/init.d scripts?
Received wisdom is that the System V
rcscripts must have an LSB header, and are run in parallel without honouring the priorities imposed by the/etc/rc?.d/system. This is incorrect on all points.
In fact, they don't need to have an LSB header, and if they do not systemd-sysv-generator can recognize the more limited old RedHat comment headers (
description:,pidfile:, and so forth). Moreover, in the absence of an LSB header it will fall back to the contents of the/etc/rc?.dsymbolic link farms, reading the priorities encoded into the link names and constructing a before/after ordering from them, serializing the services. Not only are LSB headers not a requirement, and not only do they themselves encode before/after orderings that serialize things to an extent, the fallback behaviour in their complete absence is actually significantly non-parallelized operation.
The reason that
/etc/rc3.ddidn't appear to matter is that you probably had that script enabled via another/etc/rc?.d/directory.systemd-sysv-generatortranslates being listed in any of/etc/rc2.d/,/etc/rc3.d/, and/etc/rc4.d/into a nativeWanted-Byrelationship to systemd'smulti-user.target. Run levels are "obsolete" in the systemd world, and you can forget about them.
The question of what the search path is, is in fact actually addressed by what you quoted in your question:
systemd-sysv-generatorgenerates the service units that run the System Vrcscripts from/etc/init.d, if it doesn't find a native systemd service unit by that name already existing in the other six locations.
In more detail:
- For the scripts themselves:
systemd-sysv-generatorlooks for an environment variable namedSYSTEMD_SYSVINIT_PATH.
- If it exists, it is expected to be a conventional colon-separated search path of directories that
systemd-sysv-generatorscans one by one. - If it does not exist, or if it has an empty value,
systemd-sysv-generatorfalls back upon a compiled-in default, which in vanilla systemd is the single directory/etc/init.d/.
- If it exists, it is expected to be a conventional colon-separated search path of directories that
- Each directory is scanned for regular files that have the owner execute permission bit set on, with earlier directories in the path overriding later ones (a mechanism not really exercised in the default case of just the one directory in the search path) and the existence of service units with the same names inhibiting the generation of these nonce ones.
- For the "symbolic link farms":
- There is a similar environment variable named
SYSTEMD_SYSVRCND_PATH.
- If it exists, it is expected to be a conventional colon-separated search path of directories that
systemd-sysv-generatorscans one by one. - If it does not exist, or if it has an empty value,
systemd-sysv-generatorfalls back upon a compiled-in default, which in vanilla systemd is the single directory/etc/rc.d/.
- If it exists, it is expected to be a conventional colon-separated search path of directories that
- Each directory is scanned for subdirectories named
rc[2345].d, which are in turn scanned for directory entries that begin withSand two decimal digits and that are at least 4 characters long. The directory entries are not dereferenced.
- There is a similar environment variable named
Notice that systemd-sysv-generator …
- … does not look at the
K*stuff; - … does not check that the symbolic link farms are actually filled with symbolic links (They could be character special files or FIFOs for all that it cares, as it only looks at the names.); and
- … does not process the runlevel information from LSB comments (i.e. the
Default-Start:andDefault-Stop:comments).
Remember, in respect of the third point, that in vanilla van Smoorenburg rc the runlevel information from LSB comments does not directly control bootstrap/shutdown behaviour. That's the remit of the symbolic link farm directories. Describing van Smoorenburg rc in systemd terminology: the symbolic link farms are the service enable controls, that determine what services are automatically started at bootstrap; whereas the Default-Start: and Default-Stop: comments are (very approximately) service preset controls, that are turned into the enable controls.
This is the question I linked in my question though. There's contradiction between the book I'm reading and the answer. I can't assert which one is right!
– direprobs
Sep 24 '17 at 20:08
@direprobs Part 5 in your quote is nonsense. Systemd does not attempt to adopt processes started by some other system. I think you can write off the book for reliable technical details, after all it does not mention LSB headers.
– sourcejedi
Sep 24 '17 at 21:21
add a comment |
I marked your question as a duplicate.
Read JdeBP great answer here: How does systemd use /etc/init.d scripts?
Received wisdom is that the System V
rcscripts must have an LSB header, and are run in parallel without honouring the priorities imposed by the/etc/rc?.d/system. This is incorrect on all points.
In fact, they don't need to have an LSB header, and if they do not systemd-sysv-generator can recognize the more limited old RedHat comment headers (
description:,pidfile:, and so forth). Moreover, in the absence of an LSB header it will fall back to the contents of the/etc/rc?.dsymbolic link farms, reading the priorities encoded into the link names and constructing a before/after ordering from them, serializing the services. Not only are LSB headers not a requirement, and not only do they themselves encode before/after orderings that serialize things to an extent, the fallback behaviour in their complete absence is actually significantly non-parallelized operation.
The reason that
/etc/rc3.ddidn't appear to matter is that you probably had that script enabled via another/etc/rc?.d/directory.systemd-sysv-generatortranslates being listed in any of/etc/rc2.d/,/etc/rc3.d/, and/etc/rc4.d/into a nativeWanted-Byrelationship to systemd'smulti-user.target. Run levels are "obsolete" in the systemd world, and you can forget about them.
The question of what the search path is, is in fact actually addressed by what you quoted in your question:
systemd-sysv-generatorgenerates the service units that run the System Vrcscripts from/etc/init.d, if it doesn't find a native systemd service unit by that name already existing in the other six locations.
In more detail:
- For the scripts themselves:
systemd-sysv-generatorlooks for an environment variable namedSYSTEMD_SYSVINIT_PATH.
- If it exists, it is expected to be a conventional colon-separated search path of directories that
systemd-sysv-generatorscans one by one. - If it does not exist, or if it has an empty value,
systemd-sysv-generatorfalls back upon a compiled-in default, which in vanilla systemd is the single directory/etc/init.d/.
- If it exists, it is expected to be a conventional colon-separated search path of directories that
- Each directory is scanned for regular files that have the owner execute permission bit set on, with earlier directories in the path overriding later ones (a mechanism not really exercised in the default case of just the one directory in the search path) and the existence of service units with the same names inhibiting the generation of these nonce ones.
- For the "symbolic link farms":
- There is a similar environment variable named
SYSTEMD_SYSVRCND_PATH.
- If it exists, it is expected to be a conventional colon-separated search path of directories that
systemd-sysv-generatorscans one by one. - If it does not exist, or if it has an empty value,
systemd-sysv-generatorfalls back upon a compiled-in default, which in vanilla systemd is the single directory/etc/rc.d/.
- If it exists, it is expected to be a conventional colon-separated search path of directories that
- Each directory is scanned for subdirectories named
rc[2345].d, which are in turn scanned for directory entries that begin withSand two decimal digits and that are at least 4 characters long. The directory entries are not dereferenced.
- There is a similar environment variable named
Notice that systemd-sysv-generator …
- … does not look at the
K*stuff; - … does not check that the symbolic link farms are actually filled with symbolic links (They could be character special files or FIFOs for all that it cares, as it only looks at the names.); and
- … does not process the runlevel information from LSB comments (i.e. the
Default-Start:andDefault-Stop:comments).
Remember, in respect of the third point, that in vanilla van Smoorenburg rc the runlevel information from LSB comments does not directly control bootstrap/shutdown behaviour. That's the remit of the symbolic link farm directories. Describing van Smoorenburg rc in systemd terminology: the symbolic link farms are the service enable controls, that determine what services are automatically started at bootstrap; whereas the Default-Start: and Default-Stop: comments are (very approximately) service preset controls, that are turned into the enable controls.
I marked your question as a duplicate.
Read JdeBP great answer here: How does systemd use /etc/init.d scripts?
Received wisdom is that the System V
rcscripts must have an LSB header, and are run in parallel without honouring the priorities imposed by the/etc/rc?.d/system. This is incorrect on all points.
In fact, they don't need to have an LSB header, and if they do not systemd-sysv-generator can recognize the more limited old RedHat comment headers (
description:,pidfile:, and so forth). Moreover, in the absence of an LSB header it will fall back to the contents of the/etc/rc?.dsymbolic link farms, reading the priorities encoded into the link names and constructing a before/after ordering from them, serializing the services. Not only are LSB headers not a requirement, and not only do they themselves encode before/after orderings that serialize things to an extent, the fallback behaviour in their complete absence is actually significantly non-parallelized operation.
The reason that
/etc/rc3.ddidn't appear to matter is that you probably had that script enabled via another/etc/rc?.d/directory.systemd-sysv-generatortranslates being listed in any of/etc/rc2.d/,/etc/rc3.d/, and/etc/rc4.d/into a nativeWanted-Byrelationship to systemd'smulti-user.target. Run levels are "obsolete" in the systemd world, and you can forget about them.
The question of what the search path is, is in fact actually addressed by what you quoted in your question:
systemd-sysv-generatorgenerates the service units that run the System Vrcscripts from/etc/init.d, if it doesn't find a native systemd service unit by that name already existing in the other six locations.
In more detail:
- For the scripts themselves:
systemd-sysv-generatorlooks for an environment variable namedSYSTEMD_SYSVINIT_PATH.
- If it exists, it is expected to be a conventional colon-separated search path of directories that
systemd-sysv-generatorscans one by one. - If it does not exist, or if it has an empty value,
systemd-sysv-generatorfalls back upon a compiled-in default, which in vanilla systemd is the single directory/etc/init.d/.
- If it exists, it is expected to be a conventional colon-separated search path of directories that
- Each directory is scanned for regular files that have the owner execute permission bit set on, with earlier directories in the path overriding later ones (a mechanism not really exercised in the default case of just the one directory in the search path) and the existence of service units with the same names inhibiting the generation of these nonce ones.
- For the "symbolic link farms":
- There is a similar environment variable named
SYSTEMD_SYSVRCND_PATH.
- If it exists, it is expected to be a conventional colon-separated search path of directories that
systemd-sysv-generatorscans one by one. - If it does not exist, or if it has an empty value,
systemd-sysv-generatorfalls back upon a compiled-in default, which in vanilla systemd is the single directory/etc/rc.d/.
- If it exists, it is expected to be a conventional colon-separated search path of directories that
- Each directory is scanned for subdirectories named
rc[2345].d, which are in turn scanned for directory entries that begin withSand two decimal digits and that are at least 4 characters long. The directory entries are not dereferenced.
- There is a similar environment variable named
Notice that systemd-sysv-generator …
- … does not look at the
K*stuff; - … does not check that the symbolic link farms are actually filled with symbolic links (They could be character special files or FIFOs for all that it cares, as it only looks at the names.); and
- … does not process the runlevel information from LSB comments (i.e. the
Default-Start:andDefault-Stop:comments).
Remember, in respect of the third point, that in vanilla van Smoorenburg rc the runlevel information from LSB comments does not directly control bootstrap/shutdown behaviour. That's the remit of the symbolic link farm directories. Describing van Smoorenburg rc in systemd terminology: the symbolic link farms are the service enable controls, that determine what services are automatically started at bootstrap; whereas the Default-Start: and Default-Stop: comments are (very approximately) service preset controls, that are turned into the enable controls.
edited Sep 25 '17 at 9:34
JdeBP
39.2k481188
39.2k481188
answered Sep 24 '17 at 19:58
thecarpythecarpy
2,7391028
2,7391028
This is the question I linked in my question though. There's contradiction between the book I'm reading and the answer. I can't assert which one is right!
– direprobs
Sep 24 '17 at 20:08
@direprobs Part 5 in your quote is nonsense. Systemd does not attempt to adopt processes started by some other system. I think you can write off the book for reliable technical details, after all it does not mention LSB headers.
– sourcejedi
Sep 24 '17 at 21:21
add a comment |
This is the question I linked in my question though. There's contradiction between the book I'm reading and the answer. I can't assert which one is right!
– direprobs
Sep 24 '17 at 20:08
@direprobs Part 5 in your quote is nonsense. Systemd does not attempt to adopt processes started by some other system. I think you can write off the book for reliable technical details, after all it does not mention LSB headers.
– sourcejedi
Sep 24 '17 at 21:21
This is the question I linked in my question though. There's contradiction between the book I'm reading and the answer. I can't assert which one is right!
– direprobs
Sep 24 '17 at 20:08
This is the question I linked in my question though. There's contradiction between the book I'm reading and the answer. I can't assert which one is right!
– direprobs
Sep 24 '17 at 20:08
@direprobs Part 5 in your quote is nonsense. Systemd does not attempt to adopt processes started by some other system. I think you can write off the book for reliable technical details, after all it does not mention LSB headers.
– sourcejedi
Sep 24 '17 at 21:21
@direprobs Part 5 in your quote is nonsense. Systemd does not attempt to adopt processes started by some other system. I think you can write off the book for reliable technical details, after all it does not mention LSB headers.
– sourcejedi
Sep 24 '17 at 21:21
add a comment |
I just did some trial runs on this to find out more, kind of a follow on to thecarpy's answer.
From what I can tell systemd-sysv-generator does the following: if there's a script in /etc/init.d it checks /etc/rc?.d/ and sees if it's part of "any runlevel." If it is, it adds it to that runlevel in the systemd hierarchy. It also gets Description information from the LSB headers in the init.d file. It also adds any hierarchy information from LSB
# Required-Start: bar
type line.
Things get weirder from there. If you run systemctl enable my_service it basically "farms out" to chkconfig to adjust the /etc/rc?.d directories, then runs systemctl daemon-reload after that to soak up the new information. However it runs it like /sbin/chkconfig my_service on (note that trailing on) which instructs it to turn it on for runlevels 2-5, and ignore the levels specified anywhere in the init.d file. However if you run chkconfig manually like chkconfig --add my_service then it respects the levels specified in the script.
Also weird: if there is no runlevel specified in the init.d file and it isn't yet symlinked in any /etc/rc?.d folder, then the systemd-sysv-generatoreems to assume you want it to be started in runlevel 4 and 5.
Plus, even if your default starting runlevel is 3, that's the same as 4 and 5. So basically it seems to assume you want to start it, no matter what, despite it not being symlinked in any rc?.d dirs.
Also if the init.d script does specify runlevels but is absent from all rc?.d dirs (a la chkconfig --del my_service or its equivalent systemctl disable my_service, or if chkconfig was never run on it) then the systemd-sysv-generator does not enable it, so it is left "disabled" And then it seems to not show up in the lists if you run systemctl list-units --all etc.
Also of note, there are two ways to specify the runlevel, both chkconfig and systemctl seem to "prefer LSB over the "old style"
chkconfig man page says:
Each service which should be manageable by chkconfig needs two or more commented lines added to its init.d script.
...
# chkconfig: 2345 20 80
# description: Saves and restores system entropy pool for
# higher quality random number generation.
chkconfig also supports LSB-style init stanzas, and will apply them in preference to "chkconfig:" lines where available. A LSB stanza looks like:
### BEGIN INIT INFO
# Provides: foo
# Required-Start: bar
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: Foo init script
### END INIT INFO
So in general that book doesn't seem quite in a right oder. The systemd-sysv-generator runs very early on in the boot phase, and sets up services (as specified above) and also enables them in the "run level equivalent" target if it deems they should be autorun. Then the boot proceeds, and starts up all services in the normal systemd order.
So, to answer the question, it uses a combination of etc/init.d and/etc/rc?.deach timesystemd` loads or reloads. In whacky ways.
add a comment |
I just did some trial runs on this to find out more, kind of a follow on to thecarpy's answer.
From what I can tell systemd-sysv-generator does the following: if there's a script in /etc/init.d it checks /etc/rc?.d/ and sees if it's part of "any runlevel." If it is, it adds it to that runlevel in the systemd hierarchy. It also gets Description information from the LSB headers in the init.d file. It also adds any hierarchy information from LSB
# Required-Start: bar
type line.
Things get weirder from there. If you run systemctl enable my_service it basically "farms out" to chkconfig to adjust the /etc/rc?.d directories, then runs systemctl daemon-reload after that to soak up the new information. However it runs it like /sbin/chkconfig my_service on (note that trailing on) which instructs it to turn it on for runlevels 2-5, and ignore the levels specified anywhere in the init.d file. However if you run chkconfig manually like chkconfig --add my_service then it respects the levels specified in the script.
Also weird: if there is no runlevel specified in the init.d file and it isn't yet symlinked in any /etc/rc?.d folder, then the systemd-sysv-generatoreems to assume you want it to be started in runlevel 4 and 5.
Plus, even if your default starting runlevel is 3, that's the same as 4 and 5. So basically it seems to assume you want to start it, no matter what, despite it not being symlinked in any rc?.d dirs.
Also if the init.d script does specify runlevels but is absent from all rc?.d dirs (a la chkconfig --del my_service or its equivalent systemctl disable my_service, or if chkconfig was never run on it) then the systemd-sysv-generator does not enable it, so it is left "disabled" And then it seems to not show up in the lists if you run systemctl list-units --all etc.
Also of note, there are two ways to specify the runlevel, both chkconfig and systemctl seem to "prefer LSB over the "old style"
chkconfig man page says:
Each service which should be manageable by chkconfig needs two or more commented lines added to its init.d script.
...
# chkconfig: 2345 20 80
# description: Saves and restores system entropy pool for
# higher quality random number generation.
chkconfig also supports LSB-style init stanzas, and will apply them in preference to "chkconfig:" lines where available. A LSB stanza looks like:
### BEGIN INIT INFO
# Provides: foo
# Required-Start: bar
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: Foo init script
### END INIT INFO
So in general that book doesn't seem quite in a right oder. The systemd-sysv-generator runs very early on in the boot phase, and sets up services (as specified above) and also enables them in the "run level equivalent" target if it deems they should be autorun. Then the boot proceeds, and starts up all services in the normal systemd order.
So, to answer the question, it uses a combination of etc/init.d and/etc/rc?.deach timesystemd` loads or reloads. In whacky ways.
add a comment |
I just did some trial runs on this to find out more, kind of a follow on to thecarpy's answer.
From what I can tell systemd-sysv-generator does the following: if there's a script in /etc/init.d it checks /etc/rc?.d/ and sees if it's part of "any runlevel." If it is, it adds it to that runlevel in the systemd hierarchy. It also gets Description information from the LSB headers in the init.d file. It also adds any hierarchy information from LSB
# Required-Start: bar
type line.
Things get weirder from there. If you run systemctl enable my_service it basically "farms out" to chkconfig to adjust the /etc/rc?.d directories, then runs systemctl daemon-reload after that to soak up the new information. However it runs it like /sbin/chkconfig my_service on (note that trailing on) which instructs it to turn it on for runlevels 2-5, and ignore the levels specified anywhere in the init.d file. However if you run chkconfig manually like chkconfig --add my_service then it respects the levels specified in the script.
Also weird: if there is no runlevel specified in the init.d file and it isn't yet symlinked in any /etc/rc?.d folder, then the systemd-sysv-generatoreems to assume you want it to be started in runlevel 4 and 5.
Plus, even if your default starting runlevel is 3, that's the same as 4 and 5. So basically it seems to assume you want to start it, no matter what, despite it not being symlinked in any rc?.d dirs.
Also if the init.d script does specify runlevels but is absent from all rc?.d dirs (a la chkconfig --del my_service or its equivalent systemctl disable my_service, or if chkconfig was never run on it) then the systemd-sysv-generator does not enable it, so it is left "disabled" And then it seems to not show up in the lists if you run systemctl list-units --all etc.
Also of note, there are two ways to specify the runlevel, both chkconfig and systemctl seem to "prefer LSB over the "old style"
chkconfig man page says:
Each service which should be manageable by chkconfig needs two or more commented lines added to its init.d script.
...
# chkconfig: 2345 20 80
# description: Saves and restores system entropy pool for
# higher quality random number generation.
chkconfig also supports LSB-style init stanzas, and will apply them in preference to "chkconfig:" lines where available. A LSB stanza looks like:
### BEGIN INIT INFO
# Provides: foo
# Required-Start: bar
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: Foo init script
### END INIT INFO
So in general that book doesn't seem quite in a right oder. The systemd-sysv-generator runs very early on in the boot phase, and sets up services (as specified above) and also enables them in the "run level equivalent" target if it deems they should be autorun. Then the boot proceeds, and starts up all services in the normal systemd order.
So, to answer the question, it uses a combination of etc/init.d and/etc/rc?.deach timesystemd` loads or reloads. In whacky ways.
I just did some trial runs on this to find out more, kind of a follow on to thecarpy's answer.
From what I can tell systemd-sysv-generator does the following: if there's a script in /etc/init.d it checks /etc/rc?.d/ and sees if it's part of "any runlevel." If it is, it adds it to that runlevel in the systemd hierarchy. It also gets Description information from the LSB headers in the init.d file. It also adds any hierarchy information from LSB
# Required-Start: bar
type line.
Things get weirder from there. If you run systemctl enable my_service it basically "farms out" to chkconfig to adjust the /etc/rc?.d directories, then runs systemctl daemon-reload after that to soak up the new information. However it runs it like /sbin/chkconfig my_service on (note that trailing on) which instructs it to turn it on for runlevels 2-5, and ignore the levels specified anywhere in the init.d file. However if you run chkconfig manually like chkconfig --add my_service then it respects the levels specified in the script.
Also weird: if there is no runlevel specified in the init.d file and it isn't yet symlinked in any /etc/rc?.d folder, then the systemd-sysv-generatoreems to assume you want it to be started in runlevel 4 and 5.
Plus, even if your default starting runlevel is 3, that's the same as 4 and 5. So basically it seems to assume you want to start it, no matter what, despite it not being symlinked in any rc?.d dirs.
Also if the init.d script does specify runlevels but is absent from all rc?.d dirs (a la chkconfig --del my_service or its equivalent systemctl disable my_service, or if chkconfig was never run on it) then the systemd-sysv-generator does not enable it, so it is left "disabled" And then it seems to not show up in the lists if you run systemctl list-units --all etc.
Also of note, there are two ways to specify the runlevel, both chkconfig and systemctl seem to "prefer LSB over the "old style"
chkconfig man page says:
Each service which should be manageable by chkconfig needs two or more commented lines added to its init.d script.
...
# chkconfig: 2345 20 80
# description: Saves and restores system entropy pool for
# higher quality random number generation.
chkconfig also supports LSB-style init stanzas, and will apply them in preference to "chkconfig:" lines where available. A LSB stanza looks like:
### BEGIN INIT INFO
# Provides: foo
# Required-Start: bar
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: Foo init script
### END INIT INFO
So in general that book doesn't seem quite in a right oder. The systemd-sysv-generator runs very early on in the boot phase, and sets up services (as specified above) and also enables them in the "run level equivalent" target if it deems they should be autorun. Then the boot proceeds, and starts up all services in the normal systemd order.
So, to answer the question, it uses a combination of etc/init.d and/etc/rc?.deach timesystemd` loads or reloads. In whacky ways.
edited 2 hours ago
answered 3 hours ago
rogerdpackrogerdpack
4061413
4061413
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f394187%2fwhat-is-the-default-path-that-systemd-uses-to-locate-locate-system-v-scripts%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Possible duplicate of How does systemd use /etc/init.d scripts?
– thecarpy
Sep 24 '17 at 19:55
@thecarpy it's certainly related - and the OP has even referenced this same question/answer in their own question (above). But they're not duplicates; this one's asking about the search path, and that's not defined in any of the answers of your proposed duplicate
– roaima
Sep 24 '17 at 20:20
1
§6.4.8 of M. Ward's book is in need of some heavy revision for the 3rd edition. There are a lot of errors in there, starting with the incorrect statement that systemd activates any runlevel targets. systemd does not work that way.
– JdeBP
Sep 25 '17 at 4:52
@JdeBP I wonder why systemd is one of the most misunderstood inits. In the answer you've provided in your comment, you state that
systemd-sysv-generator: "merges the/etc/rc[234].ddirectories into just the oneWanted-Byrelationship tomulti-user.targetin generated service units." What about the LSB headers? AFAIK, the LSB headers used to determine the order and the dependencies of the scripts in/etc/init.d. Without LSB, the fallback option isrc?.dI don't really quite understand the whole process involved here. Red Hat guys give us magic but don't tell us how it works!– direprobs
Sep 25 '17 at 8:01