[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: script execution on the machine when its boots



Rodney Richison wrote:

>
>Brent Clark wrote:
>
>>Hi all
>>
>>I have a firewall / gateway ruleset that I want excuted when the
>>machine needs to reboot.
>>
>>I placed the script in /etc/network/if-up.d, but I found that on doing
>>so, the script did not execute.
>>
>>Would anyone know how and where I can place my script for execution on
>>the machine when its boots up.
>>
>>Kind Regards
>>Brent Clark
>>
> 1. Execute this command to find your default runlevel:
> cat /etc/inittab | grep initdefault
> You should see a line like this:
> id:2:initdefault:
> That means 2 is your default runlevel. This may also be 3, or
>rarely 4 or 5.
> 2. Create your rc.local file like this (as root):
> touch /etc/init.d/rc.local
> chmod 774 /etc/init.d/rc.local
> Put the command into the /etc/init.d/rc.local file
>
>echo hello world
>
> 3. update-rc.d -f rc.local start 99 2 3 4 5 .
># Note - you must leave the period in with a space before it.
>

If the script is a firewall / gateway rule set, you might find it
easier and potentially more secure to add to the interface in
/etc/network/interfaces a post-up command to run the script, eg:

auto eth0
iface eth0 inet static
address 192.168.0.1
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
post-up /full/path/to/firewall.gateway.ruleset.script

Potentially more secure as it activates the firewall straight after
bringing up the interface, rather than a few seconds later :)

Regards

Hagakure

 



Reply to: