If you’re like most solaris/linux/unix sysadmins, you occasionally need to whip up a quick init script for an app that doesn’t provide one, or that has one that’s not appropriate for your particular environments. Needing just such a thing myself recently, I decided to not just throw together the bare minimum, but to spend a few extra minutes putting together something that met the following:
- Flexible: minimal dependencies or environmental assumptions.
- Simple: as easy as possible to read and understand
- Configurable: having to grep through a script to remove references to a binary’s path isn’t acceptable
The script below meets these requirements pretty well. It depends only on bash and pkill, it seems pretty readable (to me, at least… YMMV), and all of the configuration happens in a few variables at the top of the script. So, without further ado:
