tech-userlevel archive

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

running multiple httpds



I have a machine where I run more than one instance of httpd(8). To do
so, I have patched the httpd rc script like below. It allows me to
symlink the rc script to e.g. httpd_site1, and set $httpd_site1_wwwdir,
$httpd_site1_wwwaddr, etc.
The ugly thing about it (except the kinda hard to read eval
statements), is the abuse of $_file from run_rc_script(). So, what do
you guys think; is this useful enough to export the $_file variable,
e.g. as $script_name and modify the script in -base?

kind regards
dieter


--- /etc/rc.d/httpd     2012-08-10 12:39:20.000000000 +0200
+++ -   2012-08-15 17:25:13.000000000 +0200
@@ -9,14 +9,24 @@
 
 $_rc_subr_loaded . /etc/rc.subr
 
-name="httpd"
+if [ -n "$_file" ]; then
+       name="${_file##*/}"
+else
+       name="${0##*/}"
+fi
 rcvar=$name
-command="/usr/libexec/${name}"
+command="/usr/libexec/httpd"
+pidfile="/var/run/${name}.pid"
 
 load_rc_config $name
 
-httpd_wwwuser_arg=${httpd_wwwuser:+-U \'$httpd_wwwuser\'}
-command_args="$httpd_wwwuser_arg -b '$httpd_wwwdir'"
-required_dirs="$httpd_wwwdir"
+eval httpd_wwwaddr_arg="\${${name}_wwwaddr:+-i \'\$${name}_wwwaddr\'}"
+eval httpd_wwwport_arg="\${${name}_wwwport:+-I \'\$${name}_wwwport\'}"
+eval httpd_wwwuser_arg="\${${name}_wwwuser:-$httpd_wwwuser}"
+httpd_wwwuser_arg=${httpd_wwwuser_arg:+-U \'$httpd_wwwuser_arg\'}
+eval httpd_wwwdir_arg="\${${name}_wwwdir:-$httpd_wwwdir}"
+command_args="$httpd_wwwaddr_arg $httpd_wwwport_arg $httpd_wwwuser_arg"
+command_args="$command_args -P $pidfile -b '$httpd_wwwdir_arg'"
+required_dirs="$httpd_wwwdir_arg"
 
 run_rc_command "$1"


Home | Main Index | Thread Index | Old Index