So, I decided last night to have a complete reorg of my httpd.conf. I broke each of the virtual hosts up into their own files, so I have /virtual/twoshortplanks.com/www/conf/httpd.conf for example, and then use the Include directive to bring them into the main file. This means that all the stuff for each virtual host is truly under /virtual now and makes things like backing up a lot clearer.
However, I want to go a little further. I'm fed up taking down and bringing up the main servers every time I want to change a config change (which is quite often when I'm playing around with AxKit for example.) So I want to be able to run each virtual host standalone on a high port as well as run it as part of the main server. To this end I've split the remaining main httpd.conf into a common.conf and all.conf. And I've implemented a standalone.conf for each virtual host that uses the common.conf and starts the high-port server.
This is all fine and dandy, but what I want is an apachectl for each of these development servers. Which leads me to a problem. They're written in bash. Has anyone got any idea how to referrer to a file relative to the bash script itself (i.e. what Perl's FindBin module does?.) I really don't want to have to have a apachectl file that's hardcoded for each and every server.
mydir=`dirname $0`
Of course, this forks an external command, so you might prefer the builtin, but slightly uglier syntax
mydir=${0%/*}
-Dom
Re:dirname
2shortplanks on 2004-08-11T09:29:26
The problem with dirname is that (unlike FindBin) it doesn't give me an absolute path. Which causes things later in the scipt to go very very wrong.Re:dirname
Dom2 on 2004-08-13T07:14:48
In that case, you need something like:dir=`dirname $0`
fulldir=`cd $dir && pwd`-Dom