[plug] checking for existence of an application

Craig Ringer craig at postnewspapers.com.au
Sat Aug 9 02:14:07 WST 2003


Jon Miller wrote:

> This is what I plan to do, but I wanted to complete the script over the
> weekend and then make a minor change when I get on site.
> 
> I'll try it on a regular RH distro with postfix and then make the
> changes later.  I was hoping that there was a way to do this generically
> as I've mentioned before.  But if not then so be it.

Hmm... how about a generic script that sources config info from an 
external file? The file need only contain simple info. If you were using 
the bash shell for the script (you didn't mention what language/shell 
you were using), maybe:

/etc/mtascript.cfg:
MTA=sendmail
MTAPATH=/usr/lib/sendmail

mtascript:
#!/bin/bash
case "$1" in
	restart)
	/etc/init.d/$MTA restart
	;;

etc

Sound reasonable? That way you're not playing dangerous guessing games, 
but can easily restart the right service every time with only a tiny bit 
of config work.

  Note: may have stuffed up case statement, I rarely do any shell scripting.

Craig



More information about the plug mailing list