Removed some tabs

svn path=/nixos/trunk/; revision=32051
This commit is contained in:
Sander van der Burg 2012-02-06 14:04:15 +00:00
parent 82ca072c23
commit 4249f803ad

View File

@ -28,8 +28,8 @@ in
extraGroups = mkOption { extraGroups = mkOption {
default = []; default = [];
example = [ "users" ]; example = [ "users" ];
description = "Defines extra groups to which the tomcat user belongs."; description = "Defines extra groups to which the tomcat user belongs.";
}; };
user = mkOption { user = mkOption {
@ -110,7 +110,7 @@ in
uid = config.ids.uids.tomcat; uid = config.ids.uids.tomcat;
description = "Tomcat user"; description = "Tomcat user";
home = "/homeless-shelter"; home = "/homeless-shelter";
extraGroups = cfg.extraGroups; extraGroups = cfg.extraGroups;
}; };
jobs.tomcat = jobs.tomcat =
@ -123,212 +123,212 @@ in
preStart = preStart =
'' ''
# Create the base directory # Create the base directory
mkdir -p ${cfg.baseDir} mkdir -p ${cfg.baseDir}
# Create a symlink to the bin directory of the tomcat component # Create a symlink to the bin directory of the tomcat component
ln -sfn ${tomcat}/bin ${cfg.baseDir}/bin ln -sfn ${tomcat}/bin ${cfg.baseDir}/bin
# Create a conf/ directory # Create a conf/ directory
mkdir -p ${cfg.baseDir}/conf mkdir -p ${cfg.baseDir}/conf
chown ${cfg.user}:${cfg.group} ${cfg.baseDir}/conf chown ${cfg.user}:${cfg.group} ${cfg.baseDir}/conf
# Symlink the config files in the conf/ directory (except for catalina.properties and server.xml) # Symlink the config files in the conf/ directory (except for catalina.properties and server.xml)
for i in $(ls ${tomcat}/conf | grep -v catalina.properties | grep -v server.xml) for i in $(ls ${tomcat}/conf | grep -v catalina.properties | grep -v server.xml)
do do
ln -sfn ${tomcat}/conf/$i ${cfg.baseDir}/conf/`basename $i` ln -sfn ${tomcat}/conf/$i ${cfg.baseDir}/conf/`basename $i`
done done
# Create subdirectory for virtual hosts # Create subdirectory for virtual hosts
mkdir -p ${cfg.baseDir}/virtualhosts mkdir -p ${cfg.baseDir}/virtualhosts
# Create a modified catalina.properties file # Create a modified catalina.properties file
# Change all references from CATALINA_HOME to CATALINA_BASE and add support for shared libraries # Change all references from CATALINA_HOME to CATALINA_BASE and add support for shared libraries
sed -e 's|''${catalina.home}|''${catalina.base}|g' \ sed -e 's|''${catalina.home}|''${catalina.base}|g' \
-e 's|shared.loader=|shared.loader=''${catalina.base}/shared/lib/*.jar|' \ -e 's|shared.loader=|shared.loader=''${catalina.base}/shared/lib/*.jar|' \
${tomcat}/conf/catalina.properties > ${cfg.baseDir}/conf/catalina.properties ${tomcat}/conf/catalina.properties > ${cfg.baseDir}/conf/catalina.properties
# Create a modified server.xml which also includes all virtual hosts # Create a modified server.xml which also includes all virtual hosts
sed -e "/<Engine name=\"Catalina\" defaultHost=\"localhost\">/a\ ${ sed -e "/<Engine name=\"Catalina\" defaultHost=\"localhost\">/a\ ${
toString (map (virtualHost: ''<Host name=\"${virtualHost.name}\" appBase=\"virtualhosts/${virtualHost.name}/webapps\" unpackWARs=\"true\" autoDeploy=\"true\" xmlValidation=\"false\" xmlNamespaceAware=\"false\" >${if cfg.logPerVirtualHost then ''<Valve className=\"org.apache.catalina.valves.AccessLogValve\" directory=\"logs/${virtualHost.name}\" prefix=\"${virtualHost.name}_access_log.\" pattern=\"combined\" resolveHosts=\"false\"/>'' else ""}</Host>'') cfg.virtualHosts)}" \ toString (map (virtualHost: ''<Host name=\"${virtualHost.name}\" appBase=\"virtualhosts/${virtualHost.name}/webapps\" unpackWARs=\"true\" autoDeploy=\"true\" xmlValidation=\"false\" xmlNamespaceAware=\"false\" >${if cfg.logPerVirtualHost then ''<Valve className=\"org.apache.catalina.valves.AccessLogValve\" directory=\"logs/${virtualHost.name}\" prefix=\"${virtualHost.name}_access_log.\" pattern=\"combined\" resolveHosts=\"false\"/>'' else ""}</Host>'') cfg.virtualHosts)}" \
${tomcat}/conf/server.xml > ${cfg.baseDir}/conf/server.xml ${tomcat}/conf/server.xml > ${cfg.baseDir}/conf/server.xml
# Create a logs/ directory # Create a logs/ directory
mkdir -p ${cfg.baseDir}/logs mkdir -p ${cfg.baseDir}/logs
chown ${cfg.user}:${cfg.group} ${cfg.baseDir}/logs chown ${cfg.user}:${cfg.group} ${cfg.baseDir}/logs
${if cfg.logPerVirtualHost then ${if cfg.logPerVirtualHost then
toString (map (h: '' toString (map (h: ''
mkdir -p ${cfg.baseDir}/logs/${h.name} mkdir -p ${cfg.baseDir}/logs/${h.name}
chown ${cfg.user}:${cfg.group} ${cfg.baseDir}/logs/${h.name} chown ${cfg.user}:${cfg.group} ${cfg.baseDir}/logs/${h.name}
'') cfg.virtualHosts) else ''''} '') cfg.virtualHosts) else ''''}
# Create a temp/ directory # Create a temp/ directory
mkdir -p ${cfg.baseDir}/temp mkdir -p ${cfg.baseDir}/temp
chown ${cfg.user}:${cfg.group} ${cfg.baseDir}/temp chown ${cfg.user}:${cfg.group} ${cfg.baseDir}/temp
# Create a lib/ directory # Create a lib/ directory
mkdir -p ${cfg.baseDir}/lib mkdir -p ${cfg.baseDir}/lib
chown ${cfg.user}:${cfg.group} ${cfg.baseDir}/lib chown ${cfg.user}:${cfg.group} ${cfg.baseDir}/lib
# Create a shared/lib directory # Create a shared/lib directory
mkdir -p ${cfg.baseDir}/shared/lib mkdir -p ${cfg.baseDir}/shared/lib
chown ${cfg.user}:${cfg.group} ${cfg.baseDir}/shared/lib chown ${cfg.user}:${cfg.group} ${cfg.baseDir}/shared/lib
# Create a webapps/ directory # Create a webapps/ directory
mkdir -p ${cfg.baseDir}/webapps mkdir -p ${cfg.baseDir}/webapps
chown ${cfg.user}:${cfg.group} ${cfg.baseDir}/webapps chown ${cfg.user}:${cfg.group} ${cfg.baseDir}/webapps
# Symlink all the given common libs files or paths into the lib/ directory # Symlink all the given common libs files or paths into the lib/ directory
for i in ${tomcat} ${toString cfg.commonLibs} for i in ${tomcat} ${toString cfg.commonLibs}
do do
if [ -f $i ] if [ -f $i ]
then then
# If the given web application is a file, symlink it into the common/lib/ directory # If the given web application is a file, symlink it into the common/lib/ directory
ln -sfn $i ${cfg.baseDir}/lib/`basename $i` ln -sfn $i ${cfg.baseDir}/lib/`basename $i`
elif [ -d $i ] elif [ -d $i ]
then then
# If the given web application is a directory, then iterate over the files # If the given web application is a directory, then iterate over the files
# in the special purpose directories and symlink them into the tomcat tree # in the special purpose directories and symlink them into the tomcat tree
for j in $i/lib/* for j in $i/lib/*
do do
ln -sfn $j ${cfg.baseDir}/lib/`basename $j` ln -sfn $j ${cfg.baseDir}/lib/`basename $j`
done done
fi fi
done done
# Symlink all the given shared libs files or paths into the shared/lib/ directory # Symlink all the given shared libs files or paths into the shared/lib/ directory
for i in ${toString cfg.sharedLibs} for i in ${toString cfg.sharedLibs}
do do
if [ -f $i ] if [ -f $i ]
then then
# If the given web application is a file, symlink it into the common/lib/ directory # If the given web application is a file, symlink it into the common/lib/ directory
ln -sfn $i ${cfg.baseDir}/shared/lib/`basename $i` ln -sfn $i ${cfg.baseDir}/shared/lib/`basename $i`
elif [ -d $i ] elif [ -d $i ]
then then
# If the given web application is a directory, then iterate over the files # If the given web application is a directory, then iterate over the files
# in the special purpose directories and symlink them into the tomcat tree # in the special purpose directories and symlink them into the tomcat tree
for j in $i/shared/lib/* for j in $i/shared/lib/*
do do
ln -sfn $j ${cfg.baseDir}/shared/lib/`basename $j` ln -sfn $j ${cfg.baseDir}/shared/lib/`basename $j`
done done
fi fi
done done
# Symlink all the given web applications files or paths into the webapps/ directory # Symlink all the given web applications files or paths into the webapps/ directory
for i in ${toString cfg.webapps} for i in ${toString cfg.webapps}
do do
if [ -f $i ] if [ -f $i ]
then then
# If the given web application is a file, symlink it into the webapps/ directory # If the given web application is a file, symlink it into the webapps/ directory
ln -sfn $i ${cfg.baseDir}/webapps/`basename $i` ln -sfn $i ${cfg.baseDir}/webapps/`basename $i`
elif [ -d $i ] elif [ -d $i ]
then then
# If the given web application is a directory, then iterate over the files # If the given web application is a directory, then iterate over the files
# in the special purpose directories and symlink them into the tomcat tree # in the special purpose directories and symlink them into the tomcat tree
for j in $i/webapps/* for j in $i/webapps/*
do do
ln -sfn $j ${cfg.baseDir}/webapps/`basename $j` ln -sfn $j ${cfg.baseDir}/webapps/`basename $j`
done done
# Also symlink the configuration files if they are included # Also symlink the configuration files if they are included
if [ -d $i/conf/Catalina ] if [ -d $i/conf/Catalina ]
then then
for j in $i/conf/Catalina/* for j in $i/conf/Catalina/*
do do
mkdir -p ${cfg.baseDir}/conf/Catalina/localhost mkdir -p ${cfg.baseDir}/conf/Catalina/localhost
ln -sfn $j ${cfg.baseDir}/conf/Catalina/localhost/`basename $j` ln -sfn $j ${cfg.baseDir}/conf/Catalina/localhost/`basename $j`
done done
fi fi
fi fi
done done
${toString (map (virtualHost: '' ${toString (map (virtualHost: ''
# Create webapps directory for the virtual host # Create webapps directory for the virtual host
mkdir -p ${cfg.baseDir}/virtualhosts/${virtualHost.name}/webapps mkdir -p ${cfg.baseDir}/virtualhosts/${virtualHost.name}/webapps
# Modify ownership # Modify ownership
chown ${cfg.user}:${cfg.group} ${cfg.baseDir}/virtualhosts/${virtualHost.name}/webapps chown ${cfg.user}:${cfg.group} ${cfg.baseDir}/virtualhosts/${virtualHost.name}/webapps
# Symlink all the given web applications files or paths into the webapps/ directory # Symlink all the given web applications files or paths into the webapps/ directory
# of this virtual host # of this virtual host
for i in "${if virtualHost ? webapps then toString virtualHost.webapps else ""}" for i in "${if virtualHost ? webapps then toString virtualHost.webapps else ""}"
do do
if [ -f $i ] if [ -f $i ]
then then
# If the given web application is a file, symlink it into the webapps/ directory # If the given web application is a file, symlink it into the webapps/ directory
ln -sfn $i ${cfg.baseDir}/virtualhosts/${virtualHost.name}/webapps/`basename $i` ln -sfn $i ${cfg.baseDir}/virtualhosts/${virtualHost.name}/webapps/`basename $i`
elif [ -d $i ] elif [ -d $i ]
then then
# If the given web application is a directory, then iterate over the files # If the given web application is a directory, then iterate over the files
# in the special purpose directories and symlink them into the tomcat tree # in the special purpose directories and symlink them into the tomcat tree
for j in $i/webapps/* for j in $i/webapps/*
do do
ln -sfn $j ${cfg.baseDir}/virtualhosts/${virtualHost.name}/webapps/`basename $j` ln -sfn $j ${cfg.baseDir}/virtualhosts/${virtualHost.name}/webapps/`basename $j`
done done
# Also symlink the configuration files if they are included # Also symlink the configuration files if they are included
if [ -d $i/conf/Catalina ] if [ -d $i/conf/Catalina ]
then then
for j in $i/conf/Catalina/* for j in $i/conf/Catalina/*
do do
mkdir -p ${cfg.baseDir}/conf/Catalina/${virtualHost.name} mkdir -p ${cfg.baseDir}/conf/Catalina/${virtualHost.name}
ln -sfn $j ${cfg.baseDir}/conf/Catalina/${virtualHost.name}/`basename $j` ln -sfn $j ${cfg.baseDir}/conf/Catalina/${virtualHost.name}/`basename $j`
done done
fi fi
fi fi
done done
'' ''
) cfg.virtualHosts) } ) cfg.virtualHosts) }
# Create a work/ directory # Create a work/ directory
mkdir -p ${cfg.baseDir}/work mkdir -p ${cfg.baseDir}/work
chown ${cfg.user}:${cfg.group} ${cfg.baseDir}/work chown ${cfg.user}:${cfg.group} ${cfg.baseDir}/work
${if cfg.axis2.enable then ${if cfg.axis2.enable then
'' ''
# Copy the Axis2 web application # Copy the Axis2 web application
cp -av ${pkgs.axis2}/webapps/axis2 ${cfg.baseDir}/webapps cp -av ${pkgs.axis2}/webapps/axis2 ${cfg.baseDir}/webapps
# Turn off addressing, which causes many errors # Turn off addressing, which causes many errors
sed -i -e 's%<module ref="addressing"/>%<!-- <module ref="addressing"/> -->%' ${cfg.baseDir}/webapps/axis2/WEB-INF/conf/axis2.xml sed -i -e 's%<module ref="addressing"/>%<!-- <module ref="addressing"/> -->%' ${cfg.baseDir}/webapps/axis2/WEB-INF/conf/axis2.xml
# Modify permissions on the Axis2 application # Modify permissions on the Axis2 application
chown -R ${cfg.user}:${cfg.group} ${cfg.baseDir}/webapps/axis2 chown -R ${cfg.user}:${cfg.group} ${cfg.baseDir}/webapps/axis2
# Symlink all the given web service files or paths into the webapps/axis2/WEB-INF/services directory # Symlink all the given web service files or paths into the webapps/axis2/WEB-INF/services directory
for i in ${toString cfg.axis2.services} for i in ${toString cfg.axis2.services}
do do
if [ -f $i ] if [ -f $i ]
then then
# If the given web service is a file, symlink it into the webapps/axis2/WEB-INF/services # If the given web service is a file, symlink it into the webapps/axis2/WEB-INF/services
ln -sfn $i ${cfg.baseDir}/webapps/axis2/WEB-INF/services/`basename $i` ln -sfn $i ${cfg.baseDir}/webapps/axis2/WEB-INF/services/`basename $i`
elif [ -d $i ] elif [ -d $i ]
then then
# If the given web application is a directory, then iterate over the files # If the given web application is a directory, then iterate over the files
# in the special purpose directories and symlink them into the tomcat tree # in the special purpose directories and symlink them into the tomcat tree
for j in $i/webapps/axis2/WEB-INF/services/* for j in $i/webapps/axis2/WEB-INF/services/*
do do
ln -sfn $j ${cfg.baseDir}/webapps/axis2/WEB-INF/services/`basename $j` ln -sfn $j ${cfg.baseDir}/webapps/axis2/WEB-INF/services/`basename $j`
done done
# Also symlink the configuration files if they are included # Also symlink the configuration files if they are included
if [ -d $i/conf/Catalina ] if [ -d $i/conf/Catalina ]
then then
for j in $i/conf/Catalina/* for j in $i/conf/Catalina/*
do do
ln -sfn $j ${cfg.baseDir}/conf/Catalina/localhost/`basename $j` ln -sfn $j ${cfg.baseDir}/conf/Catalina/localhost/`basename $j`
done done
fi fi
fi fi
done done
'' ''
else ""} else ""}
${pkgs.su}/bin/su -s ${pkgs.bash}/bin/sh ${cfg.user} -c 'CATALINA_BASE=${cfg.baseDir} JAVA_HOME=${pkgs.jdk} JAVA_OPTS="${cfg.javaOpts}" CATALINA_OPTS="${cfg.catalinaOpts}" ${tomcat}/bin/startup.sh' ${pkgs.su}/bin/su -s ${pkgs.bash}/bin/sh ${cfg.user} -c 'CATALINA_BASE=${cfg.baseDir} JAVA_HOME=${pkgs.jdk} JAVA_OPTS="${cfg.javaOpts}" CATALINA_OPTS="${cfg.catalinaOpts}" ${tomcat}/bin/startup.sh'
''; '';