PDA

View Full Version : rc.local not executed



pshi
7th September 2007, 10:49 PM
I installed F7 to my laptop from live CD. My script in rc.local file is not executed on boot.
I have to manually execute the script from the command line after I login.
This did not happen however to my desktop with F7.

Anyone can help? What is the right way to have my script executed automatically on boot?

brr872002
8th September 2007, 08:13 AM
Try
gedit /etc/rc.d/rc3.d/S99local
or
gedit /etc/rc.d/rc5.d/S99local

pshi
8th September 2007, 06:16 PM
These are all symbolic links to the real rc.local in /etc/rc.d. Editing these files in my opining is
equivalent to ed/etc/rc.d/rc.local. The fact is, whatever I do, the file
/etc/rc.d/rc.local is not executed on boot. What can be the potential problems?

leigh123linux
8th September 2007, 06:25 PM
Did you make your script executable ?

pshi
8th September 2007, 10:05 PM
Here is the setting.



[root@localhost rc.d]# ls -l rc.local
-rwxr-xr-x 1 root root 442 2007-09-08 08:28 rc.local
[root@localhost rc.d]# cat rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
#define ip static address for eth1
ifconfig eth1 192.168.1.102 netmask 255.255.255.0 broadcast 192.168.1.255
#add new route
route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.1
route add default gw 192.168.1.1


Did I make a syntax mistake or something?

marcelkraan
8th September 2007, 10:27 PM
:-) yes use the network in :
/etc/sysconfig/network-scripts/ifcfg-eth1

DEVICE=eth1
BOOTPROTO=static
HWADDR=00:C0:9F:9B:11:71
ONBOOT=yes
NETMASK=
IPADDR=
TYPE=Ethernet
USERCTL=no
IPV6INIT=no
PEERDNS=yes



Here is the setting.



[root@localhost rc.d]# ls -l rc.local
-rwxr-xr-x 1 root root 442 2007-09-08 08:28 rc.local
[root@localhost rc.d]# cat rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
#define ip static address for eth1
ifconfig eth1 192.168.1.102 netmask 255.255.255.0 broadcast 192.168.1.255
#add new route
route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.1
route add default gw 192.168.1.1


Did I make a syntax mistake or something?

pshi
9th September 2007, 01:02 PM
The issue is why rc.local is not executed on boot. The solution you provided does not solve this issue.
The strange thing is, this does not happen to my desktop PC with the same FC 7. The only difference is on my laptop the OS is installed from live CD while on my desktop it is installed from the full DVD.

I thought rc.local should be executed automatically on boot in all linux distribution. I do not think I made a syntax error either since the same command I added in the file can be executed from the command line.

More help needed.
Thanks

leigh123linux
9th September 2007, 01:08 PM
try



touch /var/lock/subsys/local
#define ip static address for eth1
/sbin/ifconfig eth1 192.168.1.102 netmask 255.255.255.0 broadcast 192.168.1.255
#add new route
/sbin/route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.1
/sbin/route add default gw 192.168.1.1

pshi
9th September 2007, 03:38 PM
Hi, leigh:

Your suggestion did not have any effect. /sbin/route and route and the same since the path /sbin is set for the root.
Here is the output.

After implementing your suggestion and reboot

Command--> route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.1.0 * 255.255.255.0 U 0 0 0 eth1
default Linksys 0.0.0.0 UG 0 0 0 eth1

After I manually execute /etc/rc.d/rc.local file at a gnome terminal:

Command--> route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.1.0 Linksys 255.255.255.0 UG 0 0 0 eth1
192.168.1.0 * 255.255.255.0 U 0 0 0 eth1
default Linksys 0.0.0.0 UG 0 0 0 eth1

As you can see, a new line is added in the routing table. This is really weird.

brr872002
10th September 2007, 06:13 AM
use kde >Development> Kompare front end

open /etc/rc.d/init.d/functions with of you PC check difference

marcelo.costa
20th September 2007, 12:39 PM
Hi.
I have a similar issue. My new FC7 x64 installation is not running rc.local too. Here is my rc.local:
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
export http_proxy=http://www.bra.xerox.com:8000
export ftp_proxy=http://www.bra.xerox.com:8000
export https_proxy=http://www.bra.xerox.com:8000
All permissions are ok, and the S99local script is linked to rc.local in rc3.d and rc5.d folders.

gthill
20th September 2007, 03:57 PM
Here is the setting.



[root@localhost rc.d]# ls -l rc.local
-rwxr-xr-x 1 root root 442 2007-09-08 08:28 rc.local
[root@localhost rc.d]# cat rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
#define ip static address for eth1
ifconfig eth1 192.168.1.102 netmask 255.255.255.0 broadcast 192.168.1.255
#add new route
route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.1
route add default gw 192.168.1.1


Did I make a syntax mistake or something?
[gordon@lap1 ~]$ ls -l /etc/rc.local
lrwxrwxrwx 1 root root 18 2007-09-08 23:53 /etc/rc.local -> /etc/rc.d/rc.local
[gordon@lap1 ~]$

If you have copied your /etc/rc.local file from a previous installation then you overwrite the link which is /etc/rc.local with a file /etc/rc.local which does nothing at boot time.
The file that executes at boot is /etc/rc.d/rc.local.
to fix:
You will need to copy the contents or your current /etc/rc.local file to the actual executable
/etc/rc.d/rc.local file and then re-create the link

ln -s /etc/rc.d/rc.local /etc/rc.local

You must be root