Red HatThis forum is for the discussion of Red Hat Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I've written a shell script to load up my wlan card - everything from modprobe to dhcpd - but at the moment I'm having to go into a root shell and run it manually.
How would I make it so that it runs when all the other hardware is initialised?
I use FC3.
[EDIT]
Oh dear... I didn't notice that Fedora forum. Can somebody move this, please?
Last edited by Napalm Llama; 04-17-2005 at 11:39 AM.
I don't know with distro do you use, but most distros have some rcX.d directories at /etc or at /etc/something. Scripts on those dirs run on a specific order (the scipts at rcX.d where X is a number run on the natural order from 1 to 5).
Each one of those directories have files nammed as SXX* or KXX*, where XX is a 2 digit number. The scripts that start with K run first, receiving the argument "stop". Then, the scripts that start with S run, receiving the argument "start". The order that the K and S scripts run are given by their numbers, so it is K00*, K01*, ..., K99*, S00*, S01*, ..., S99*.
You need to discover where the scripts that depend on your are and make sure it runs first.
Thing is, my script runs and then stops - if something ran it with the argument 'stop', it would just run again.
If it starts a service, you should name it SXX*, if it stops one, you should name it KXX*. If it just set some configuration, or anything that doesn't deal with deamons, you should name it SXX*. But the name is not so restrct, the only differences between them are the order of execution and the argument, any one will work fine (but your system will be hard to understand if you use a K script to start something or a S one to stop).
Quote:
I have directories 0 thru 6, which I'm assuming refer to the runlevels.
Yes, those directories refer to runlevels. There may also be a rcS.d that refer to runlevel S (the one that executes before 0), but I am not sure, because they usualy start at 1 (so, on your system, S may be 0). You put your script everywere you need it to run. So, if you need it to run once, before some others (that depend on it), put it on a place that will be reached before the others. If you need to run it every runlevel, put it on every runlevel, but remember that runlevel S always run, and that runlevels 1 to 6 run everytime you reach a runlevel bigger or equal to them. That mean, if your system is going untill runlevel 5, it runs, on that order, runlevels S, 0, 1, 2, 3, 4 and 5, so, it is very rare to need something on all of them. I would recommend you to put your script with a number as hight as possible (to make it execute as late as possible), so it interferes with as little others as possible. Runlevel S is special because, when you type linux single at Lilo prompt, you just run it, so, if you want your script to run even if you are on a single section, you need to put it there.
Also, notice that those directories only have symbolic links. This is the usual way to add scripts to them, the script is located at /etc/init.d and is linked from the directories that you want.
The script in question sets up networking support, so I'll probably put it near the beginning of Runlevel 3.
Only one problem - I put it in an rcX.d directory before, named S07wlansetup I think, and it wasn't run. I think that was rc3.d, so what's going on there?
It should run. Maybe you put it on the wrong place (not in rcX.d), maybe you didn't set executable permission or maybe there something wrong with the script.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.