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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

boot script

Status
Not open for further replies.

vascobrito

Technical User
Feb 27, 2003
28
PT
hi there
how can i run a script on bootup?
i tried to search something about inittab, but i didn't find anything usefull. This is a script wich have some route commands to map wan network, so i can overide the scrit using flush, but i can only access this server if it's routes are defined. therefor i need the server to run this script on bootup.
thans for any help and sorry about my english
thanks
 
Put a startup script in /etc/rc2.d with the routes you want added.
 
I'm not sure if a separate script is what you need to achieve what you want. Those with better networking experience might have some other ways to achieve what you want to do.

But, in general (this might be more info that you need):

Take a look at the scripts in /sbin/init.d. These are the scripts that are available to be run when the system starts or shuts down and are written in such a way that the same script can be used both at startup and shutdown. You will notice that some have a reference to a file /etc/rc.config.d. This isn’t totally necessary, but can be useful.

Take a look at /etc/rc.config.d. The files here will have a statement like RUN_MYSCRIPT=0 or RUN_MYSCRIPT=1.

Then take a look at the contents of /sbin/rc2.d. Do a long listing of the directory and you will see that the files in that directory are links to the scripts in /sbin/init.d. There are other /sbin/rcx.d directories. Files that begin with S (for start) are run when the system starts up. Files that begin with K (for kill) are run when the system shuts down. The files are invoked in order: S100myscript would run before S900myscript, for example.

So, let’s say your fully debugged script [wink] is named myscript.

Put myscript into /sbin/init.d.

If you have a reference to /etc/rc.config.d/myscript, make sure you have that file there with RUN_MAYSCRIPT=1. (1 means to run it, 0 means don’t).

Then, in /sbin/rc2.d, make a link to the actual script in /sbin/init.d. Let’s say it’s the last script you want to run at startup when the system reaches run level 2. Use this command in /sbin/rc2.d:

ln –s /sbin/init.d/myscript S999myscript

And, by the way, your English is fine.
 
sorry for the typo:

RUN_MAYSCRIPT=1 should be RUN_MYSCRIPT=1
 
Thanks
I have followed what you said and i'll try it tonight.
When the server restarts it should have the script loaded.
I'll tell you tomorrow how it went.
Again, thanks for your explanation, since i was able to undestand how it works instead of justing putting it to work.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top