Bug 10508

Summary: rc-local.service is not enabled and impossible to enable
Product: Mageia Reporter: Denis Chupau <d.chupau>
Component: RPM PackagesAssignee: Colin Guthrie <mageia>
Status: RESOLVED INVALID QA Contact:
Severity: normal    
Priority: Normal CC: mageia
Version: 3   
Target Milestone: ---   
Hardware: i586   
OS: Linux   
Whiteboard:
Source RPM: systemd-units CVE:
Status comment:

Description Denis Chupau 2013-06-12 15:05:55 CEST
Description of problem:
I installed MGA3 minimal i586.
I added a script /etc/rc.d/rc.local as such :
#!/bin/bash
my command...

I made it executable.
=> It was never executed
The cause was : it was not enabled in systemd
BUT I was not able to enable it using systemctl.
Systemctl would fail stating : no "[install]" section in rc-local.service.


Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
1. boot the computer
2. try to enable rc-local.service
3.


Solution :
I added at the bottom of /usr/lib/systemd/system/rc-local.service :

[install]
WantedBy=multi-user.target


Then I could enable the rc-local service that is effectively executed at boot now.

regards
Dag

Reproducible: 

Steps to Reproduce:
Sander Lepik 2013-06-12 17:02:27 CEST

CC: (none) => sander.lepik
Assignee: bugsquad => mageia

Comment 1 Colin Guthrie 2013-06-12 17:43:37 CEST
It's not meant to be enabled by default, as there is a generator that ensures it is pulled into multi-user.target if /etc/rc.d/rc.local is executable.

So adding an [Install] section is the wrong solution and if you read /usr/lib/systemd/system/rc-local.service it clearly states:

# This unit gets pulled automatically into multi-user.target by
# systemd-rc-local-generator if /etc/rc.d/rc.local is executable.

So the question is, is /usr/lib/systemd/system-generators/systemd-rc-local-generator not working???


After booting what are the contents of /run/systemd/generator/ and more specifically does the folder /run/systemd/generator/multi-user.target.wants/ exist and does it have a symlink to rc-local.service in it?


While this could be a bug that should be fixed, I should note that rc-local.service is a compatibility kludge. If you are creating new scripts to be run at boot, it would be better to write your own systemd units in /etc/systemd/system and enable them directly, especially if your "local" jobs do not have to be run sequentially, but can be run in parallel - in which case you can create several separate units for each of the jobs you want.
Comment 2 Colin Guthrie 2013-06-12 17:47:27 CEST
For reference, testing the generator works fine for me:

[root@plateau ~]# touch /etc/rc.d/rc.local
[root@plateau ~]# chmod a+x !$
chmod a+x /etc/rc.d/rc.local
[root@plateau ~]# ls /tmp/
gpg-B60Jfa/  gpg-g12qDu/  gpg-G2DaZq/  gpg-Swi3ea/  gpg-ZLGg3n/
[root@plateau ~]# /usr/lib/systemd/system-generators/systemd-rc-local-generator
[root@plateau ~]# ls /tmp
gpg-B60Jfa/  gpg-g12qDu/  gpg-G2DaZq/  gpg-Swi3ea/  gpg-ZLGg3n/  multi-user.target.wants/
[root@plateau ~]# ls -l /tmp/multi-user.target.wants/
total 0
lrwxrwxrwx 1 root root 40 Jun 12 16:44 rc-local.service -> /usr/lib/systemd/system/rc-local.service
Comment 3 Denis Chupau 2013-06-13 17:15:44 CEST
Ok, thanks !

But are there any documentations anywhere about the 
"/usr/lib/systemd/system-generators/systemd-rc-local-generator"

Because I didn't find a page about this (either manpage or document on the web).


So where users can get this information ?


regards,
Dag
Comment 4 Colin Guthrie 2013-06-13 17:24:27 CEST
The generator is mostly an implementation detail and users shouldn't need to know about it. If they have an existing rc.local script or write a new one and reboot it should be run fine on the next boot.

I'm still not sure why it doesn't work for you generally tho', so can you provide the answers to the questions asked in comment 2?
Comment 5 Denis Chupau 2013-07-10 12:33:53 CEST
Hi,

Ok, this is old stuff, I don't know what happened then.

I remember having rebooted, and rc.local didn't execute, so maybe I did some other mistake.

I re-tested with a fresh install (MGA3 i586) :
- created the /etc/rc.d/rc.local script,
- chmod +x,
- reboot : it worked flawlessly.
It's working flawlessly since then.


That's why I think I did some mistake somewhere in the first install.


Sorry about this.


May I close this bug then ?


regards,
Dag
Comment 6 Colin Guthrie 2013-07-11 10:35:38 CEST
Cool, thanks for re-testing and glad it seems to be working as expected (i.e. magically without any user intervention!)

And yes, lets close this one now :)

Status: NEW => RESOLVED
Resolution: (none) => INVALID