kickstart and rc.local

Issues related to configuring your network
Post Reply
ghoril
Posts: 9
Joined: 2015/05/21 14:09:42

kickstart and rc.local

Post by ghoril » 2015/05/21 14:26:56

Hi,
I am deploying centos 7 via kickstart.
/etc/rc.local is no works after kickstart install and this causes two problems.

I use this file to finish off other install features from the network.

Problem 1:
Works perfectly in previous versions however even after adding the following in kickstart file:
services --enabled=rc-local

it does not start the service.
After kickstart install I see the following error:

systemctl status rc-local
rc-local.service - /etc/rc.local Compatibility
Loaded: loaded (/etc/systemd/system/rc-local.service; disabled)
Active: failed (Result: exit-code) since Wed 2015-05-20 12:08:49 BST; 1 day 3h ago
Process: 557 ExecStart=/etc/rc.local start (code=exited, status=32)

systemd[1]: rc-local.service: control process exited, code=exited status=32
systemd[1]: Failed to start /etc/rc.local Compatibility.
systemd[1]: Unit rc-local.service entered failed state.


I want /etc/rc.local script to execute at first reboot following kickstart install.
In kickstart %post install I chmod 755 /etc/rc.d/rc.local but this does not execute the file.
After logging in and enabling rc-local and starting the service it works but I want the file to be enabled and active after the kickstart install.

How do I achieve this?

Problem 2:
After the rc-local service is enabled it fails to implement any network mounts and subsequent post install.
It seems that network only starts after a user logs on so network related dns host resolv do not work
I want networking features enabled and working before the rc-local service so I can mount network nfs shares.
Any way to do this?

Hoping to hear soon.
Last edited by ghoril on 2015/05/21 15:00:39, edited 1 time in total.

gerald_clark
Posts: 10642
Joined: 2005/08/05 15:19:54
Location: Northern Illinois, USA

Re: kickstart and rc.local

Post by gerald_clark » 2015/05/21 14:57:57

1. /etc/rc.local is supposed to be a symlink to /etc/rc.d/rc.local. Have you broken the symlink? Make sure you are setting /etc/rc.d/rc.local to 755.
2. This is covered in the FAQ http://wiki.centos.org/FAQ/CentOS7.

ghoril
Posts: 9
Joined: 2015/05/21 14:09:42

Re: kickstart and rc.local

Post by ghoril » 2015/05/21 14:59:30

Hi, yes I know it is a symlink to /etc/rc.d/rc.local and the link is not broken.

aks
Posts: 3069
Joined: 2014/09/20 11:22:14

Re: kickstart and rc.local

Post by aks » 2015/05/21 16:14:28

So I take it you've done systemctl enable rc-local.service
and you have one of:
/etc/systemd/system/rc-local.service
/lib/systemd/system/rc-local.service
And that you script start with a #!/bin/bash (or the appropriate shell/interpreter)?

This bit:
Process: 557 ExecStart=/etc/rc.local start (code=exited, status=32)
suggests to me that your script is exiting code 32. What happens if you execute it?

As for the "wait for network" thing, I seem to recall a service called NetworkManager-wait-online.service (at least on Fedora). Perhaps that's an avenue to pursue? Alternatively, you could do something like, read the output of ip link sh to determine if the link is up (or even ip addr sh to ensure you get an address). In the past I've done something like wget http://www.google.co.uk > /dev/null 2>&1 and read the return ($?) to indicate pass or fail.

ghoril
Posts: 9
Joined: 2015/05/21 14:09:42

Re: kickstart and rc.local

Post by ghoril » 2015/05/22 15:32:16

Hi yes to all of this:
"So I take it you've done systemctl enable rc-local.service
and you have one of:
/etc/systemd/system/rc-local.service
/lib/systemd/system/rc-local.service
And that you script start with a #!/bin/bash (or the appropriate shell/interpreter)?"

> After logon the script /etc/rc.d/rc.local works when I execute it.
The script contains command for mounting remote nfs server and executing a script.

I have not used NetworkManager-wait-online.service how do I enable network before logon so the /etc/rc.d/rc.local script is executed.

aks
Posts: 3069
Joined: 2014/09/20 11:22:14

Re: kickstart and rc.local

Post by aks » 2015/05/22 19:07:57

> After logon the script /etc/rc.d/rc.local works when I execute it.
The script contains command for mounting remote nfs server and executing a script.
Does that mean it works as expected?

Anyway, NetworkManager-wait-online.service has a bug in CentOS (maybe fixed in 7.1?) to wit: https://bugs.centos.org/view.php?id=7825

The idea is to stop paralising startup and wait for the network to start.
Personally I'd do as I suggested earlier, get a file or read the status of the interface (perhaps something like /usr/bin/nm-online -t 30?)

ghoril
Posts: 9
Joined: 2015/05/21 14:09:42

Re: kickstart and rc.local

Post by ghoril » 2015/05/27 11:23:49

Unfortunately it still does not work.
I am trying to deploy centos 7.1
the rc.local script will mount a remote share, execute a script on this share and copy files, applications etc
After the setup I want to be able to use the script to modify the system as and when required.
Is there any other way of enabling rc.local via kickstart and then executing commands from the script at first boot?

ghoril
Posts: 9
Joined: 2015/05/21 14:09:42

Re: kickstart and rc.local

Post by ghoril » 2015/06/15 13:23:42

I thought I'll drop an update.
I have fixed this issue so rc.local works following kickstart install.

rjlohman_opt
Posts: 8
Joined: 2016/04/13 18:09:36

Re: kickstart and rc.local

Post by rjlohman_opt » 2016/05/06 16:09:40

ghoril:

Can you describe what you did to fix it?

Thanks,
RJL

aks
Posts: 3069
Joined: 2014/09/20 11:22:14

Re: kickstart and rc.local

Post by aks » 2016/05/06 16:22:44

I've started using rc.local for a a one shot config thing (which'll revert rc.local back to what it was afterwards) - mainly because I'm far to lazy to write a simple systemd unit file for it and also I don't care about the order of execution.

So in my ks, I have:
echo '#!/bin/sh' > /etc/rc.d/rc.local
echo '[the commands I want to run]' >> /etc/rc.d/rc.local
echo '[a file I write out if everything was done as I wanted it to happen]' >> /etc/rc.d/rc.local
echo '[a test for if that file exists, write the default comments back to rc.local and also chmod 0400 /etc/rc.local]' >> /etc/rc.d/rc.local
chmod 0755 /etc/rc.d/rc.local
I did NOT have to enable rc.local in systemd - it seems to run every time, only if the execute bit is set (which is why I make it chmod 0400 itself).

Works fine for me, CentOS 7.2

Post Reply