2008-01-30 12:00:59 +01:00
|
|
|
args: with args;
|
|
|
|
|
|
|
|
let
|
2008-02-19 17:52:08 +01:00
|
|
|
cfg = config.services.tomcat;
|
2008-01-30 12:00:59 +01:00
|
|
|
in
|
2008-02-19 17:52:08 +01:00
|
|
|
|
2008-01-30 12:00:59 +01:00
|
|
|
{
|
2008-02-19 17:52:08 +01:00
|
|
|
name = "tomcat";
|
2008-07-06 00:27:36 +02:00
|
|
|
|
|
|
|
groups = [
|
|
|
|
{ name = "tomcat";
|
|
|
|
gid = (import ../system/ids.nix).gids.tomcat;
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
users = [
|
|
|
|
{ name = "tomcat";
|
|
|
|
uid = (import ../system/ids.nix).uids.tomcat;
|
|
|
|
description = "Tomcat user";
|
|
|
|
home = "/homeless-shelter";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
2008-02-19 17:52:08 +01:00
|
|
|
job = ''
|
|
|
|
description "Apache Tomcat server"
|
2008-01-30 12:00:59 +01:00
|
|
|
|
2008-07-06 00:27:36 +02:00
|
|
|
start on network-interface/started
|
|
|
|
stop on network-interfaces/stop
|
|
|
|
|
|
|
|
start script
|
2008-07-23 16:13:27 +02:00
|
|
|
# Create initial state data
|
|
|
|
|
|
|
|
if ! test -d ${cfg.baseDir}
|
|
|
|
then
|
|
|
|
mkdir -p ${cfg.baseDir}/webapps
|
|
|
|
mkdir -p ${cfg.baseDir}/shared
|
2008-08-06 15:41:08 +02:00
|
|
|
mkdir -p ${cfg.baseDir}/lib
|
2008-07-23 16:13:27 +02:00
|
|
|
cp -av ${pkgs.tomcat6}/{conf,temp,logs} ${cfg.baseDir}
|
|
|
|
fi
|
|
|
|
|
2008-08-06 17:07:29 +02:00
|
|
|
# Deploy context.xml
|
|
|
|
|
|
|
|
if test "${cfg.contextXML}" = ""
|
|
|
|
then
|
|
|
|
cp ${pkgs.tomcat6}/conf/context.xml.default ${cfg.baseDir}/conf/context.xml
|
|
|
|
else
|
|
|
|
cp ${cfg.contextXML} ${cfg.baseDir}/conf/context.xml
|
|
|
|
fi
|
|
|
|
|
2008-07-23 16:13:27 +02:00
|
|
|
# Deploy all webapplications
|
|
|
|
|
|
|
|
if ! test "${cfg.deployFrom}" = ""
|
|
|
|
then
|
|
|
|
rm -rf ${cfg.baseDir}/webapps
|
|
|
|
mkdir -p ${cfg.baseDir}/webapps
|
|
|
|
for i in ${cfg.deployFrom}/*
|
|
|
|
do
|
|
|
|
cp -rL $i ${cfg.baseDir}/webapps
|
|
|
|
done
|
|
|
|
fi
|
2008-08-06 15:41:08 +02:00
|
|
|
|
2008-07-23 16:13:27 +02:00
|
|
|
# Fix permissions
|
|
|
|
|
|
|
|
chown -R ${cfg.user} ${cfg.baseDir}
|
|
|
|
|
|
|
|
for i in `find ${cfg.baseDir} -type d`
|
|
|
|
do
|
|
|
|
chmod -v 755 $i
|
|
|
|
done
|
|
|
|
|
|
|
|
for i in `find ${cfg.baseDir} -type f`
|
|
|
|
do
|
|
|
|
chmod -v 644 $i
|
|
|
|
done
|
2008-07-06 21:55:34 +02:00
|
|
|
|
2008-08-06 15:41:08 +02:00
|
|
|
# Deploy all common libraries
|
|
|
|
|
|
|
|
rm -rf ${cfg.baseDir}/lib/*
|
|
|
|
|
|
|
|
if test "${cfg.commonLibFrom}" = ""
|
|
|
|
then
|
|
|
|
commonLibFrom="${pkgs.tomcat6}/lib";
|
|
|
|
else
|
|
|
|
commonLibFrom="${cfg.commonLibFrom}";
|
|
|
|
fi
|
|
|
|
|
|
|
|
for i in $commonLibFrom/*.jar
|
|
|
|
do
|
|
|
|
ln -s $i ${cfg.baseDir}/lib
|
|
|
|
done
|
|
|
|
|
2008-07-23 16:13:27 +02:00
|
|
|
# Deploy all shared libraries
|
|
|
|
|
|
|
|
if ! test "${cfg.sharedLibFrom}" = ""
|
|
|
|
then
|
|
|
|
rm -f ${cfg.baseDir}/shared/lib
|
|
|
|
ln -s ${cfg.sharedLibFrom} ${cfg.baseDir}/shared/lib
|
|
|
|
fi
|
2008-07-06 21:55:34 +02:00
|
|
|
|
2008-07-06 00:27:36 +02:00
|
|
|
end script
|
|
|
|
|
2008-07-06 21:55:34 +02:00
|
|
|
respawn ${pkgs.su}/bin/su -s ${pkgs.bash}/bin/sh ${cfg.user} -c 'CATALINA_BASE=${cfg.baseDir} JAVA_HOME=${pkgs.jdk} JAVA_OPTS="${cfg.javaOpts}" ${pkgs.tomcat6}/bin/startup.sh; sleep 1d'
|
2008-07-06 00:27:36 +02:00
|
|
|
|
|
|
|
stop script
|
2008-07-23 16:13:27 +02:00
|
|
|
echo "Stopping tomcat..."
|
|
|
|
CATALINA_BASE=${cfg.baseDir} JAVA_HOME=${pkgs.jdk} ${pkgs.su}/bin/su -s ${pkgs.bash}/bin/sh ${cfg.user} -c ${pkgs.tomcat6}/bin/shutdown.sh
|
2008-07-06 00:27:36 +02:00
|
|
|
end script
|
2008-02-19 17:52:08 +01:00
|
|
|
'';
|
2008-01-30 12:00:59 +01:00
|
|
|
}
|