Page 1 of 2
/etc/rc.local not getting executed
Posted: 21. Nov 2015, 11:58
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.
Re: /etc/rc.local not getting executed
Posted: 21. Nov 2015, 12:42
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.
Re: /etc/rc.local not getting executed
Posted: 21. Nov 2015, 13:51
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:
Even this is not getting executed.
Re: /etc/rc.local not getting executed
Posted: 21. Nov 2015, 19:02
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.
Re: /etc/rc.local not getting executed
Posted: 21. Nov 2015, 23:03
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.
Re: /etc/rc.local not getting executed
Posted: 22. Nov 2015, 02:42
by rsal
That should work. I think ubuntu has /etc/rc.local rather than /etc/rc.d/local. Thanks.
Re: /etc/rc.local not getting executed
Posted: 22. Nov 2015, 07:41
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.
Re: /etc/rc.local not getting executed
Posted: 22. Nov 2015, 08:15
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.
Re: /etc/rc.local not getting executed
Posted: 22. Nov 2015, 09:43
by rsal
Problems -> hurrying -> more problems!
Re: /etc/rc.local not getting executed
Posted: 24. Nov 2015, 14:29
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?