LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   startup scripts (https://www.linuxquestions.org/questions/linux-newbie-8/startup-scripts-49853/)

amphion 03-14-2003 02:43 PM

startup scripts
 
Where do I put scripts so that they run at boot?

acid_kewpie 03-14-2003 02:49 PM

depends what they are really. some more information would be useful....

if it's just a nondescript script then you can added it to the end of /etc/rc.local.

bulliver 03-14-2003 02:51 PM

You can put small ones in /etc/rc.local

If your script is a seperate file you an put it anywhere and just have a reference to it in rc.local ie:

Code:

# in rc.local
/path/to/script


amphion 03-14-2003 02:53 PM

I want to run iptables and nat so I want to run this script:

iptables --flush - Flush all the rules in filter and nat tables
iptables --table nat --flush
iptables --delete-chain - Delete all chains that are not in default filter and nat table
iptables --table nat --delete-chain

# Set up IP FORWARDing and Masquerading
iptables --table nat --append POSTROUTING --out-interface ppp0 -j MASQUERADE
iptables --append FORWARD --in-interface eth0 -j ACCEPT - Assuming one NIC to local LAN

echo 1 > /proc/sys/net/ipv4/ip_forward - Enables packet forwarding by kernel

acid_kewpie 03-14-2003 02:57 PM

yeah i'd just stick that in rc.local, but if you wanted to create a full blown service file for it you should be able to.

amphion 03-14-2003 03:01 PM

Quote:

but if you wanted to create a full blown service file for it you should be able to
What do you mean with that.

Thanks for the quick replies btw :)

bulliver 03-14-2003 03:17 PM

Depending on your distro, there are files to stop and start most of your services. They are usually in /etc/rc.d but may be elsewhere. They are tough for a beginner so depending on your experience you will probably just want to stick with rc.local

For a firewall what I did was put the commands in a file called /etc/rc.d/firewall , then simply add "/etc/rc.d/firewall" to rc.local. Make sure that it is executable and has "#!/bin/bash" as the first line.

amphion 03-14-2003 03:33 PM

I have iptables running as a service/deamon. I'm running redhat 8.

I can put the above scripts in an iptables config file too? If so, where is this config file?

juggler 03-28-2003 01:39 PM

iptables config
 
The iptables config is located at:
/etc/sysconfig/iptables

Your best best is to set up your firewall using the script, then
running:
iptables-save

This rewrites your firewall setup to /etc/sysconfig/iptables.


All times are GMT -5. The time now is 01:18 PM.