From f1438d3d2731d890d8ccdda967fd7ab63d8d1d05 Mon Sep 17 00:00:00 2001 From: Rob Vermaas Date: Wed, 17 Feb 2010 12:32:19 +0000 Subject: [PATCH] tomcat: add option to enable accesslog per virtual host (default: off) svn path=/nixos/trunk/; revision=20075 --- modules/services/web-servers/tomcat.nix | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/modules/services/web-servers/tomcat.nix b/modules/services/web-servers/tomcat.nix index ef569a8fedf..bc633cb6459 100644 --- a/modules/services/web-servers/tomcat.nix +++ b/modules/services/web-servers/tomcat.nix @@ -66,6 +66,11 @@ in description = "List consisting of a virtual host name and a list of web applications to deploy on each virtual host"; }; + logPerVirtualHost = mkOption { + default = false; + description = "Whether to enable logging per virtual host."; + }; + axis2 = { enable = mkOption { @@ -125,6 +130,9 @@ in ln -sfn ${pkgs.tomcat6}/conf/$i ${cfg.baseDir}/conf/`basename $i` done + # Create subdirectory for virtual hosts + mkdir -p ${cfg.baseDir}/virtualhosts + # Create a modified catalina.properties file # Change all references from CATALINA_HOME to CATALINA_BASE and add support for shared libraries sed -e 's|''${catalina.home}|''${catalina.base}|g' \ @@ -132,7 +140,8 @@ in ${pkgs.tomcat6}/conf/catalina.properties > ${cfg.baseDir}/conf/catalina.properties # Create a modified server.xml which also includes all virtual hosts - sed -e "//a\ ${toString (map (virtualHost: '''' ) cfg.virtualHosts)}" \ + sed -e "//a\ ${ + toString (map (virtualHost: ''${if cfg.logPerVirtualHost then '''' else ""}'') cfg.virtualHosts)}" \ ${pkgs.tomcat6}/conf/server.xml > ${cfg.baseDir}/conf/server.xml # Create a logs/ directory @@ -231,7 +240,7 @@ in # Symlink all the given web applications files or paths into the webapps/ directory # of this virtual host - for i in ${toString virtualHost.webapps} + for i in "${if virtualHost ? webapps then toString virtualHost.webapps else ""}" do if [ -f $i ] then