I've just created a little initscript for the Virtualmin system that runs SciPy.org, and I thought it might be handy for others. I'm planning to add it to the stock Virtualmin Professional installer in a week or two, after I've had a chance to run it by Jamie and some other folks to be sure there are no security issues with this code (I've certainly thought of the obvious issues, symbolic links in particular, but I wouldn't suggest installing this on a system with untrusted users until it's had more than a few minutes testing and more eyes looking at it than my two).
Anyway, what this script does is pulls out a list of home directories from /etc/passwd, strips out the system users (anything below UID 500), and looks to see if there is an ~/etc/init.d directory containing executable files. If so, it executes each one with an appropriate argument (start|stop). It expects standard shell return values for success/failure and will print out a nice green OK or red FAILED on Red Hat-based systems (I'll expand this to use SUSE style ok/failure messages, etc., before including it in the installer). The scripts thus need to handle start/stop (the script handles restarting using start/stop) input. It allows you to allow your users to run "always on" processes and know that in the event of a server reboot, their services will come back up without user intervention. Most of you don't want that, but if you're hosting high-dollar application server users, they'll appreciate the convenience of this...since otherwise, they might have to resort to clever cronjobs to keep an eye on their processes.
Without further ado, you can get the script here:
It's very nearly wholly untested, and I'm not calling it ready for primetime, but I thought folks might find it interesting. And if you're reading the Hacks forums, you've got to be up for a little adventure now and then.
Installation consists of dropping it into /etc/init.d and setting the executable bit.
And just about any script in any language that accepts a single argument of "start" or "stop", and returns 0 for success and non-zero for failure, will work fine in the user's ~/etc/init.d directory. The script should not provide any additional output to the console as it will really clutter up bootup and shutdown, but logging to the users home directory logs dir would work fine (each script is executed as the user). I'll probably redirect console results for each script to /dev/null, or a standardized log location in the users home directory before calling this script done. In the short term, I just needed something that worked and was clean and reasonably secure.