/etc/rc.local not getting executed

You have a problem with Salix? Post here and we'll do what we can to help.
rsal
Posts: 198
Joined: 12. Mar 2012, 17:00

/etc/rc.local not getting executed

Post by rsal »

I have following rc.local file:

Code: Select all

# ls -l /etc/rc.local
-rwxr-xr-x 1 root root 101 Nov 21 22:53 /etc/rc.local
root[i_user]# 
root[i_user]# cat /etc/rc.local
#! /bin/bash
iptables-restore /usr/local/bin/myrules.saved
root[i_user]# 
But when I start, iptables-save command shows that there are no rules, hence above file has not been loaded. I have to load them at every startup. How can I sort this problem? Thanks.
User avatar
mimosa
Salix Warrior
Posts: 3311
Joined: 25. May 2010, 17:02
Contact:

Re: /etc/rc.local not getting executed

Post by mimosa »

Looks like that syntax is incorrect:

http://www.cyberciti.biz/faq/how-do-i-s ... -settings/

Not that it makes any difference I suppose, but that's a very strange place to keep that file. The /usr/bin directory is for executable files.
rsal
Posts: 198
Joined: 12. Mar 2012, 17:00

Re: /etc/rc.local not getting executed

Post by rsal »

I do not think syntax is a problem because the same command works all right on a root terminal after the system has started.

It is not working even after changing the command syntax (adding an '<' symbol).

I added another line:

Code: Select all

alias ll='ls -ltrk'
Even this is not getting executed.
User avatar
gapan
Salix Wizard
Posts: 6241
Joined: 6. Jun 2009, 17:40

Re: /etc/rc.local not getting executed

Post by gapan »

Your shebang is bad. Why would you change that? Why would you completely replace the original contents of the file, which include instructions on how to edit it?

The following are the original contents of the file:

Code: Select all

#!/bin/sh
#
# /etc/rc.d/rc.local:  Local system initialization script.
#
# Put any local startup commands in here.  Also, if you have
# anything that needs to be run at shutdown time you can
# make an /etc/rc.d/rc.local_shutdown script and put those
# commands in there.
Image
Image
westms
Posts: 298
Joined: 17. Mar 2013, 18:51

Re: /etc/rc.local not getting executed

Post by westms »

rsal wrote:I have following rc.local file:

Code: Select all

# ls -l /etc/rc.local
-rwxr-xr-x 1 root root 101 Nov 21 22:53 /etc/rc.local
root[i_user]# 
But when I start, iptables-save command shows that there are no rules, hence above file has not been loaded. I have to load them at every startup. How can I sort this problem? Thanks.
This is so because file rc.local has no place in directory /etc. From Gapans file excerpt you can see that it must be right /etc/rc.d/rc.local. You probably want to add your iptables-restore command to the end of this file.
rsal
Posts: 198
Joined: 12. Mar 2012, 17:00

Re: /etc/rc.local not getting executed

Post by rsal »

That should work. I think ubuntu has /etc/rc.local rather than /etc/rc.d/local. Thanks.
User avatar
mimosa
Salix Warrior
Posts: 3311
Joined: 25. May 2010, 17:02
Contact:

Re: /etc/rc.local not getting executed

Post by mimosa »

Both those "obvious" mistakes (the bad shebang, the location) could have been avoided by editing the file, with its informative instructions, in situ. (Well spotted, westms!)

I say that not to be pedantic but as a concrete example of why such a conservative approach is good practice. The more you change, the greater the chance of breaking something - whether by overlooking it, or just not knowing.
User avatar
gapan
Salix Wizard
Posts: 6241
Joined: 6. Jun 2009, 17:40

Re: /etc/rc.local not getting executed

Post by gapan »

Good catch westms! I completely overlooked that.
rsal wrote:That should work. I think ubuntu has /etc/rc.local rather than /etc/rc.d/local. Thanks.
Then again, this is not ubuntu. And again you are wrong. It isn't /etc/rc.d/local, it's /etc/rc.d/rc.local. You have to be more careful than that.
Image
Image
rsal
Posts: 198
Joined: 12. Mar 2012, 17:00

Re: /etc/rc.local not getting executed

Post by rsal »

Problems -> hurrying -> more problems!
User avatar
knome
Donor
Posts: 163
Joined: 20. Dec 2012, 19:36
Location: UK

Re: /etc/rc.local not getting executed

Post by knome »

I'm finding rsal very helpful. Has some good pointers on how not to break Salix. ;)

Is shebang the same as kit and kaboodle?
Image
Post Reply