systemd does not run /etc/rc.local?
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Light Drops
--
Chapters
00:00 Systemd Does Not Run /Etc/Rc.Local?
00:27 Answer 1 Score 29
01:08 Accepted Answer Score 16
01:45 Answer 3 Score 4
02:05 Answer 4 Score 2
02:48 Answer 5 Score 1
03:29 Thank you
--
Full question
https://superuser.com/questions/278396/s...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#archlinux
#avk47
ANSWER 1
Score 29
With systemd 188-2, systemd complains about having no [Install]
section and as such being unable to enable the rc.local service. Might have been the case with earlier versions but since Arch devs only recently announced systemd will become the default I am fixing up my system.
To fix that, just add a section for the multiuser target in /etc/systemd/system/rc-local.service
:
[Unit]
Description=/etc/rc.local Compatibility
ConditionPathExists=/etc/rc.local
[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
SysVStartPriority=99
[Install]
WantedBy=multi-user.target
Create the /etc/rc.local
script and make it executable with chmod +x /etc/rc.local
ACCEPTED ANSWER
Score 16
Arch might not have included the service unit file necessary to run rc.local
.
Just create a file /etc/systemd/system/rc-local.service
with the following contents (copied verbatim from my Fedora systemd system):
# This file is part of systemd. # # systemd is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. [Unit] Description=/etc/rc.local Compatibility ConditionPathExists=/etc/rc.local [Service] Type=forking ExecStart=/etc/rc.local start TimeoutSec=0 StandardOutput=tty RemainAfterExit=yes SysVStartPriority=99
Then, just run systemctl enable rc-local.service
as root to enable it. You can also test it/run it now by running systemctl start rc-local.service
.
ANSWER 3
Score 4
Pkgfile (on my system) says:
$ pkgfile --search rc-local.service
community/initscripts-systemd
That package installs other stuff you may not want, but you can disable it. See also: https://wiki.archlinux.org/index.php/Systemd#The_initscripts-systemd_package
ANSWER 4
Score 2
Don't forget to make rc.local executable - or the compatibility layer will not run it! In the above examples which are listed - you would run chmod a+x in order to make the rc.local file executable. As follows:
$ chmod a+X /etc/systemd/system/rc-local.service
I would think another possible problem is the location of your rc.local script! If you haven't already added the compatibility to systemd (which should be built in - and seems to be by former mention of it already existing) you may need to double check your files location... On my OS I have rc-local at /etc/rc.d/rc.local so I ran the following:
$ sudo chmod a+x /etc/rc.d/rc.local
$ sudo systemctl restart rc-local.service
$ sudo systemctl status rc-local.service
rc-local.service - /etc/rc.d/rc.local Compatibility
Loaded: loaded (/lib/systemd/system/rc-local.service; static)
Active: active (exited) since Fri, 13 Apr 2012 14:42:39 -0600; 3s ago
Process: 2285 ExecStart=/etc/rc.d/rc.local start (code=exited, status=0/SUCCESS)
CGroup: name=systemd:/system/rc-local.service
ANSWER 5
Score 1
Two common gotchas:
Don't forget to make
/etc/rc.d/rc.local
executable. You can use# chmod a+rx /etc/rc.d/rc.local
to make it executable.
Don't forget to put a
#!/bin/sh
line in the first line of/etc/rc.d/rc.local
. Here's how things should look:# head -1 /etc/rc.d/rc.local #!/bin/sh # file /etc/rc.d/rc.local /etc/rc.d/rc.local: POSIX shell script, ASCII text executable
If you don't get similar output, edit
/etc/rc.d/rc.local
to add a line at the very top containing just#!/bin/sh
.