Am 18.07.2022 um 22:18 schrieb Peter Boypboy@uni-bremen.de: wrote
I got it finally working.
After some tests: It isn’t.
The programs I have to start depend on the existence of some (virtual) network interfaces. rc.local is ordered after network.target, which doesn’t mean, the network is functional then. Therefore, the program start via rc.local is in indeterministic process. Sometimes it works, sometimes not, sometimes only for some.
Documentation mentions a drop in at/etc/systemd/system/rc-local.service.d/network.conf. But there is no subdirectory /etc/systemd/system/rc-local.service.d/
Should I really mess around with vim and mkdir in the directories managed by the distribution? Seems like a bad idea to me.
Or have I missed something?
There is a cleaner workaround, which does, unfortunately mean you have to do some minor file amendments (with vim, *of course*!)
Your original /etc/rc.d/rc.local is renamed: mv rc.local the-real-rc.local
/etc/rc.d/rc.local is replaced with a new version: <code> #!/bin/bash # to run rc.local type things, without interference from systemd # rc-local: /usr/bin/at -M now <<'HERE' > /dev/null 2>&1 /etc/rc.d/the-real-rc.local HERE
# And everything I used to run in rc.local now gets run # from the-real-rc.local, untouched by systemd meddling # (Resistance was futile, I was assimilated). </code>
Both of these files have to be executable (chmod 755).
The /usr/systemd/rc-local.service file IS NOT TOUCHED, so there are no problems with it being overwritten. (might need to be enabled. I cannot remember.)
The rc-local service checks the rc.local file, and IF it is executable, will run it. The new version rc.local calls 'the-real-rc.local'.
Your 'the-real-rc.local' file can have a sleep or structured pause until the networks respond properly and signal they are awake.
This sleight-of-hand was posted by someone on an Arch distro forum/mailing list. I do not have his name, but kudos and thanks whoever you are. It works
In addition, you can also split your 'real' file, by creating a semaphore file in /tmp, and run different sections. If you prefer you can run a 'real' files only on the first run after a boot, or even after an install. If you have not yet changed, for example, /var/lib/mysql from a directory to a link to somewhere else, then this is the first run after a re-install, and that has not yet been done: an install, in my experience, whether told to format or not to format, will wipe the /var partition, and all of the databases in that folder. I put them elsewhere and link to there, so no losses. So obviously one thing I want to do is change the folder to a link to the proper place. And obviously there are a plethora of things which need to be done *once* after an install. Needs one 'if' statement in the bash script. A re-run will skip the block.
Geoff
On Mon, 18 Jul 2022 22:25:03 -0400 R. G. Newbury wrote:
This sleight-of-hand was posted by someone on an Arch distro forum/mailing list. I do not have his name, but kudos and thanks whoever you are. It works
Those are my exact notes (and even comments) from when systemd started killing off rc.local stuff that took "too long". Maybe someone copied them from the fedora list to an arch list :-).
But I definitely didn't use vim, I used emacs :-).
I don't need rc.local any longer, I think I only needed it on my work system (and I'm now retired).