Mailing List Archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[tlug] script to disable / enable processes in rc?.d/

Hi everyone,

Reading the thread on having programs autostart got me thinking about stopping services via runlevels. From what I understand (and this is in Debian, I'm not sure about other distros) all services are initiated via symlinks in the /etc/rc?.d/ directories. The docs say:

To disable a service in this runlevel, rename its script in this directory
so that the new name begins with a 'K' and a two-digit number, where the
number is the difference between the two-digit number following the 'S'
in its current name, and 100.  To re-enable the service, rename the script
back to its original name beginning with 'S'.

This seems really めんどくさい, does anyone actually do this? It seems the other option is to delete all the symlinks in all the runlevels, and then run update-rc.d -f service remove. Or perhaps just temporarily moving the file it is symlinking to into another directory. But say like you wanted to disable the service in all runlevels as they recommend above- leaving the symlink but switching the S to a K?  I'd like to have some script to automatically do this from a shell, but I'm not sure how to do this so I thought I would ask the pros. For example to temporarily disable the process monopoly I thought of doing something like:

find /etc/rc[0-5].d/ -name 'S??monop*' -exec mv - {} /sometempdirectory  \;

This doesn't really do the trick though, I really wanted to do a regex switch on the symlink name itself, something like

find /etc/rc[0-5].d/ -name 'S??mo*' -exec sed -i 's/S/K/' \;

but of course this didn't work. I am now thinking that in order to do a regex on a group of symlinks like this, you'd have to have a script (maybe perl?) that uses strings to first cp -d the symlink to a temp location, remove the initial symlink, does the regex on the backed up symlink and them moves to each initial directory.

Has anyone done something like this? I might be reinventing the wheel or doing overdoing this simple objective, but I thought it would be useful so if anyone has any thoughts or suggestions..

Scott VanDusen

**************** CAUTION - Disclaimer *****************
This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely for the use of the addressee(s). If you are not the intended recipient, please notify the sender by e-mail and delete the original message. Further, you are not to copy, disclose, or distribute this e-mail or its contents to any other person and any such actions are unlawful. This e-mail may contain viruses. Infosys has taken every reasonable precaution to minimize this risk, but is not liable for any damage you may sustain as a result of any virus in this e-mail. You should carry out your own virus checks before opening the e-mail or attachment. Infosys reserves the right to monitor and review the content of all messages sent to or from this e-mail address. Messages sent to or from this e-mail address may be stored on the Infosys e-mail system.
***INFOSYS******** End of Disclaimer ********INFOSYS***

Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links