write a script to start a service..how??
i have done a squid installation and it was working quite ok for the time being.
now, i want to create a starting script and put it into directory /etc/rc.d/init.d, such that it will auto-start when the machine is booting. so, the question is that any idea in creating this kind of script. where should i refer to? any example of script to let me customize it in order to suit my need? i never have experiences before this. thanks!!!! |
create a text file and write this in it:
Code:
#!/bin/bash |
create a text file of what you would have
to type to start squid and save it in init.d as a name you would remember. like squidder. use chmod +x filename to make the file executable. in the runlevel that you use. maybe 3, make a softlink from inside /etc/rc.d/rc.d to the file squidder, called S99squidder like ln -s /etc/rc.d/init.d/squidder /etc/rc.d/rc.3/S99squidder then it will start last in runlevel 3 |
what is the purpose of having a starting point at runlevel 3??
then, what if i want to stop the service when the system is shutting down? will this my squid service be listed in "Service" screen list? and how to make stop, restart function for that service? thanks! |
i just guessed that your default runlevel is 3.
to make a start stop and restart service is more complicated. take one of the other scripts in /etc/init.d, copy it and rename it, and edit it to suit your needs. to have a service specifcally killed in a runlevel, like shutdown which is 6, you make a link to a script that kills squid, or you make your script more complex, so that it checks how it is called. start the kill script name with K. |
how to determine my runlevel is 3? any command prompt that will comfirm my runlevel? confusing... u mean my script will content start, restart and stop command prompts...
and then, i have to make a link to rc.3 for start and restart purposes, subsequently, i have to make another link to rc.6 for stop purpose, with prefix "k" for that link's name? i have took a glance over the rest of the scripts in /etc/rc.d/init.d. they are all look complicated... i have no idea in how to edit them...can u give an example of script that will showing a skeleton on how to customize it? thanks again!!!!! |
Runlevel 3 is the default runlevel during multi-user bootup. ie. if you bootup "normally", you'll be at runlevel 3.
To edit your rc.3 script, just open it up and insert this line: /path/to/squid --arguments where /path/to/squid is the full path to this squid application, and --arguments is any additional arguments you need to append to it (not necessary depending on how you normally run squid). |
All times are GMT -5. The time now is 04:06 PM. |