Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
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.
Hi
Ive got a debian box without a desktop environment nor a monitor...I access it through ssh...I use it as a router..Ive created a bash script that contains all the rules and IP addresses etc...I want this script to be executed everytime my router starts..the script is found in /root/ ..and it must remain there..for several reasons...
The solution I got was as follows
create a file in /etc/init.d/test
then update-rc.d test defaults 99 "I know about 99 S K and defaults"
this should allow the test file to be executed at startup..but what about a script found in /root/ ? Does update-rc.d allow me to call files not found in /init.d/ or should I just enter an entry in lets say the mentioned test file that calls the file found in root...when it is called at startup ?
I am confused about your questions, I usually put scripts that I want to run at startup in rc.local. I am pretty sure that by default these scripts run as root and therefore can access scipts owned by root in any directory. If not than change the permissions of your /etc/init.d/test file to run as "set uid".
I hope I understood your questions right and that I was of help.
Depending on what you are doing, it is also possible to add your script to the ethernet configuration scripts so that when your router connects to the internet your scripts are run right away. For instance on my laptop, I use wpa encryption, and want the wpa_supplicant to run before I connect to the internet, so I edit the
/etc/sysconfig/network-scripts/ifup-wireless
script in order to run a few commands or call another script before or right after the wireless card connects to the AP.
P.S. I like the design of your web page, it looks really nice!
Last edited by accessrichard; 02-03-2006 at 02:41 PM.
Thx..for you help...Ive got it figured out..the prob was that debian does not have a rc.local file and furthermore it differs in some particular aspects from other distros but now its done...thx again
AFAIK, there is nothing special about the /etc/init.d directory. That's just where startup scripts are stored by convention, not by mandate. I could be mistaken on this ... I've never actually tried placing an init script outside of /etc/init.d It would be simple enough to run a quick test if you wanted to.
But assuming I'm correct about scripts outside of /etc/init.d being allowable:
If you want /root/myscript to run when you hit runlevel 2, 3, and 4 for example, you should be able to do something like this:
Your /root/myscript file should understand standard startup script options, like "start", "stop", "restart", etc. I suppose if you're only creating an Sxxx link then all it's needs to understand is "start". If you also create a Kxxx script, then it needs to understand "stop".
I find those "update-rc.d" type of wrapper programs to be more trouble than just doing things manually.
To CF50... you create your script and save it in /etc/init.d/ and then you execute update-rc.d yourfilename 99 defaults ...this will add your file to the startup of your debian system..99 means that it will be the last file to be executed and defaults means that it will be added to all run-levels...to add it only to specific run levels...execute update-rc.d filename 99 s 2 3 5. "with the period at the end" and of course you can "man update-rc.d".
The issue I had was that my startup file had to be in a user directory so that a user can edit it from there "for alot of diff reasons" so I created a file in /etc/init.d/ and just told it to execute /home/directory of user/myscript.sh
That way every time the system boots it calls my file, in that file I added my firewall configuration and the progs I want to start each time. It is easier to edit the whole configuration of the system that way
Edit: Actually haertig...Iam doing it that way now.. it is always better to be closer to the actual way things work
The issue I had was that my startup file had to be in a user directory so that a user can edit it from there "for alot of diff reasons"...
Just realize that this user, actually ANY user who can write this startup file, owns your system. They can do anything they want ... as userid root. This cannot be considered secure in any way, shape or form. However, everybody's situation is different and maybe your setup does not require much security (possibly YOU are the only user, etc.)
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.