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!

run a script on startup...

Status
Not open for further replies.

mackey333

Technical User
May 10, 2001
563
US
Ok these are the instructions in the readme file of a program:

Code:
If you want it to run automatically when the machine is booted, then
place the following script in your startup directory. (/etc/init.d/rcX.d
or /sbin/init.d/rcX.d or ???) 

	#######################################################
	#! /bin/sh
	case "$1" in
	    start)
		echo "Starting noip."
		/usr/local/bin/noip
	    ;;
	    stop)
		echo -n "Shutting down noip."
		killproc -TERM /usr/local/bin/noip
	    ;;
	    *)
		echo "Usage: $0 {start|stop}"
		exit 1
	esac
	exit 0
	#######################################################

Where the 'X' in rcX.d is the value obtained by running the 
following command
	grep initdefault /etc/inittab | awk -F: '{print $2}'

now..when i type the command in, X=3...but there is now rc3.d file in init.d..there are no rc* files at all. I created the file and put the code there but nothing happended...it didn't echo to the console on reboot. Where should I put the script? -Greg :-Q

flaga.gif
 
The startup scripts themselves go in /etc/init.d (Mandrake and RedHat). Then you make a symlink in /etc/rcX.d to the startup script in /etc/init.d. There's a program in Mandrake called "chkconfig" that makes this a little easier (in Debian there's an "update-rcd" or similar) that looks for a line in the init script like this:
Code:
# chkconfig: 2345 20 10
The 2345 is what run levels to start the program in, the 20 is where it goes in the "pecking order" of programs to start (if your script is ip address related, make sure you start it after the network has been activated, or at least modules loaded for NIC, modem, etc), and the 10 is where to shut the program down when rebooting/changing runlevels.

So, I'd just paste sample line above into the start of the initscript you have, then run:
Code:
chkconfig --add noip

It's worth mentioning that if you are running RedHat or Mandrake, if you boot into graphical mode (X) you are booting into runlevel 5, so if nothing else:
Code:
ln -s /etc/init.d/noip /etc/rc5.d/S30noip

Okay, so I'm rambling. Really need some sleep ;-) --
JR
 
If you can not get the script to work using chkconfig and run-levels, then edit the /etc/rc.d/rc.local file and call your script at the very end.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top