Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Where to put my init/config script

Status
Not open for further replies.

regJoe

Technical User
Nov 27, 2002
6
AT
Hi all,

I'm a serious newby so sorry if this turns out to be a dumb question...

I would like to set my ethernet card to a fixed IP address, (have a small closed network) - using the command:

ifconfig eth0 192.168.0.2 netmask 255.255.255.0 up

(GUI-tool gives a blocking bug when trying to apply changes).

I would like to include this in some script that is executed at startup; e.g. myIPConfig. Where should i put it?

- init.d, referring to it (link) from all relevant runlevel dirs, eg rc.3 and rc.5?

I noticed that this init.d dir only contains more complex stuff that uses expressions like exit; mine is however just some silly config setting!!!

So:

- Generally, where are network settings kept?
- And, where are config scripts typically put that apply to all runlevels and users?

Hope somebody can help me out on both these questions...


Thx, help very much appreciated!!!
 
Sorry, that would be

Linux Redhat 2.4.18-14 #1
 
eh, Red Hat 8.0, kernel 2.4.18-14...
 
Good.

You don't have to add that command anywhere.

Take a look in /etc/sysconfig/network-scripts. There you should find a file named "ifcfg-eth0". You can edit that file and place the changes there.

To set the default gateway, edit /etc/sysconfig/network

To set your DNS settings, edit
/etc/resolv.conf

You'll have to be root to do all this. ______________________________________________________________________
TANSTAAFL!
 
Thanx, great info.

So about the other question, where in general do i put scripts and settings that affect some or all users?

(e.g. kernel parameter settings for an Oracle db installation)

would that be in the .bash_profile of the affected users, in the .bashrc, or more in some central init location, somewhere in the init.d planes?

thx
 
If you want commands to run at system startup, put them at the end of the /etc/rc.d/rc.local file.

If you want to set environment variables for all users, put them in /etc/profile (for individual users, sleipnir214 answered that above, ~/.bash_profile).

If you want a script to execute for a certain runlevel at system startup, drop it in /etc/rc.d/rcX.d, where X is the runlevel you are booting into (3 is text mode startup, 5 is GUI startup). Actually, the way its normally done, is to drop the script in /etc/rc.d/init.d and then create a symlink to the appropriate rcX.d directorie(s). When putting a script (or a symlink to a script) in one of the rcX.d directories, make sure to name the file "S##script". The 'S' means to start the script (while a K means to kill it if its running), and the ## is a number that identifies what order the script will be executed. Make sure to use a number that isn't being used already.


ChrisP
 
To add to fluid11's excellent post, there's a program named "
Code:
chkconfig
" in Mandrake (so I'm assuming Redhat too). The point is, take your script you want run, put it in
Code:
/etc/init.d
. Put a line in your script like this:
Code:
# chkconfig 2345 20 80
The "2345" part means "start this program in runlevels 2,3,4, and 5". The "20" means "it's start priority is 20". The "80" means "it's shut-down priority is 80".

What's this do? Saves you from having to make a bunch of symlinks manually. If you need to tweak when your script starts during bootup, it's an easy adjustment. For more details, check out "
Code:
man chkconfig
.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top