Convert "tomcat"
svn path=/nixos/branches/fix-style/; revision=14380
This commit is contained in:
parent
b17f9995d5
commit
eacbb7c38e
@ -480,53 +480,6 @@ in
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
tomcat = {
|
|
||||||
enable = mkOption {
|
|
||||||
default = false;
|
|
||||||
description = "Whether to enable Apache Tomcat";
|
|
||||||
};
|
|
||||||
|
|
||||||
baseDir = mkOption {
|
|
||||||
default = "/var/tomcat";
|
|
||||||
description = "Location where Tomcat stores configuration files, webapplications and logfiles";
|
|
||||||
};
|
|
||||||
|
|
||||||
user = mkOption {
|
|
||||||
default = "tomcat";
|
|
||||||
description = "User account under which Apache Tomcat runs.";
|
|
||||||
};
|
|
||||||
|
|
||||||
deployFrom = mkOption {
|
|
||||||
default = "";
|
|
||||||
description = "Location where webapplications are stored. Leave empty to use the baseDir.";
|
|
||||||
};
|
|
||||||
|
|
||||||
javaOpts = mkOption {
|
|
||||||
default = "";
|
|
||||||
description = "Parameters to pass to the Java Virtual Machine which spawns Apache Tomcat";
|
|
||||||
};
|
|
||||||
|
|
||||||
catalinaOpts = mkOption {
|
|
||||||
default = "";
|
|
||||||
description = "Parameters to pass to the Java Virtual Machine which spawns the Catalina servlet container";
|
|
||||||
};
|
|
||||||
|
|
||||||
sharedLibFrom = mkOption {
|
|
||||||
default = "";
|
|
||||||
description = "Location where shared libraries are stored. Leave empty to use the baseDir.";
|
|
||||||
};
|
|
||||||
|
|
||||||
commonLibFrom = mkOption {
|
|
||||||
default = "";
|
|
||||||
description = "Location where common libraries are stored. Leave empty to use the baseDir.";
|
|
||||||
};
|
|
||||||
|
|
||||||
contextXML = mkOption {
|
|
||||||
default = "";
|
|
||||||
description = "Location of the context.xml to use. Leave empty to use the default.";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
httpd = {
|
httpd = {
|
||||||
|
|
||||||
enable = mkOption {
|
enable = mkOption {
|
||||||
@ -1302,6 +1255,7 @@ in
|
|||||||
(import ../upstart-jobs/gnunet.nix)
|
(import ../upstart-jobs/gnunet.nix)
|
||||||
(import ../upstart-jobs/ejabberd.nix) # untested, dosen't compile on x86_64-linux
|
(import ../upstart-jobs/ejabberd.nix) # untested, dosen't compile on x86_64-linux
|
||||||
(import ../upstart-jobs/jboss.nix)
|
(import ../upstart-jobs/jboss.nix)
|
||||||
|
(import ../upstart-jobs/tomcat.nix) # untested, too lazy to get that jdk
|
||||||
|
|
||||||
# nix
|
# nix
|
||||||
(import ../upstart-jobs/nix.nix) # nix options and daemon
|
(import ../upstart-jobs/nix.nix) # nix options and daemon
|
||||||
|
@ -174,12 +174,6 @@ let
|
|||||||
inherit config pkgs;
|
inherit config pkgs;
|
||||||
})
|
})
|
||||||
|
|
||||||
# Apache Tomcat service
|
|
||||||
++ optional config.services.tomcat.enable
|
|
||||||
(import ../upstart-jobs/tomcat.nix {
|
|
||||||
inherit config pkgs;
|
|
||||||
})
|
|
||||||
|
|
||||||
# Samba service.
|
# Samba service.
|
||||||
++ optional config.services.samba.enable
|
++ optional config.services.samba.enable
|
||||||
(import ../upstart-jobs/samba.nix {
|
(import ../upstart-jobs/samba.nix {
|
||||||
|
@ -1,109 +1,175 @@
|
|||||||
args: with args;
|
{pkgs, config, ...}:
|
||||||
|
|
||||||
|
###### interface
|
||||||
|
let
|
||||||
|
inherit (pkgs.lib) mkOption mkIf;
|
||||||
|
|
||||||
|
options = {
|
||||||
|
services = {
|
||||||
|
tomcat = {
|
||||||
|
enable = mkOption {
|
||||||
|
default = false;
|
||||||
|
description = "Whether to enable Apache Tomcat";
|
||||||
|
};
|
||||||
|
|
||||||
|
baseDir = mkOption {
|
||||||
|
default = "/var/tomcat";
|
||||||
|
description = "Location where Tomcat stores configuration files, webapplications and logfiles";
|
||||||
|
};
|
||||||
|
|
||||||
|
user = mkOption {
|
||||||
|
default = "tomcat";
|
||||||
|
description = "User account under which Apache Tomcat runs.";
|
||||||
|
};
|
||||||
|
|
||||||
|
deployFrom = mkOption {
|
||||||
|
default = "";
|
||||||
|
description = "Location where webapplications are stored. Leave empty to use the baseDir.";
|
||||||
|
};
|
||||||
|
|
||||||
|
javaOpts = mkOption {
|
||||||
|
default = "";
|
||||||
|
description = "Parameters to pass to the Java Virtual Machine which spawns Apache Tomcat";
|
||||||
|
};
|
||||||
|
|
||||||
|
catalinaOpts = mkOption {
|
||||||
|
default = "";
|
||||||
|
description = "Parameters to pass to the Java Virtual Machine which spawns the Catalina servlet container";
|
||||||
|
};
|
||||||
|
|
||||||
|
sharedLibFrom = mkOption {
|
||||||
|
default = "";
|
||||||
|
description = "Location where shared libraries are stored. Leave empty to use the baseDir.";
|
||||||
|
};
|
||||||
|
|
||||||
|
commonLibFrom = mkOption {
|
||||||
|
default = "";
|
||||||
|
description = "Location where common libraries are stored. Leave empty to use the baseDir.";
|
||||||
|
};
|
||||||
|
|
||||||
|
contextXML = mkOption {
|
||||||
|
default = "";
|
||||||
|
description = "Location of the context.xml to use. Leave empty to use the default.";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
in
|
||||||
|
|
||||||
|
###### implementation
|
||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.services.tomcat;
|
cfg = config.services.tomcat;
|
||||||
in
|
in
|
||||||
|
|
||||||
{
|
mkIf config.services.tomcat.enable {
|
||||||
name = "tomcat";
|
require = [
|
||||||
|
options
|
||||||
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";
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
job = ''
|
|
||||||
description "Apache Tomcat server"
|
|
||||||
|
|
||||||
start on network-interface/started
|
services = {
|
||||||
stop on network-interfaces/stop
|
extraJobs = [{
|
||||||
|
name = "tomcat";
|
||||||
start script
|
|
||||||
# Create initial state data
|
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";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
job = ''
|
||||||
|
description "Apache Tomcat server"
|
||||||
|
|
||||||
|
start on network-interface/started
|
||||||
|
stop on network-interfaces/stop
|
||||||
|
|
||||||
if ! test -d ${cfg.baseDir}
|
start script
|
||||||
then
|
# Create initial state data
|
||||||
mkdir -p ${cfg.baseDir}/webapps
|
|
||||||
mkdir -p ${cfg.baseDir}/shared
|
if ! test -d ${cfg.baseDir}
|
||||||
mkdir -p ${cfg.baseDir}/lib
|
then
|
||||||
cp -av ${pkgs.tomcat6}/{conf,temp,logs} ${cfg.baseDir}
|
mkdir -p ${cfg.baseDir}/webapps
|
||||||
fi
|
mkdir -p ${cfg.baseDir}/shared
|
||||||
|
mkdir -p ${cfg.baseDir}/lib
|
||||||
# Deploy context.xml
|
cp -av ${pkgs.tomcat6}/{conf,temp,logs} ${cfg.baseDir}
|
||||||
|
fi
|
||||||
if test "${cfg.contextXML}" = ""
|
|
||||||
then
|
# Deploy context.xml
|
||||||
cp ${pkgs.tomcat6}/conf/context.xml.default ${cfg.baseDir}/conf/context.xml
|
|
||||||
else
|
if test "${cfg.contextXML}" = ""
|
||||||
cp ${cfg.contextXML} ${cfg.baseDir}/conf/context.xml
|
then
|
||||||
fi
|
cp ${pkgs.tomcat6}/conf/context.xml.default ${cfg.baseDir}/conf/context.xml
|
||||||
|
else
|
||||||
# Deploy all webapplications
|
cp ${cfg.contextXML} ${cfg.baseDir}/conf/context.xml
|
||||||
|
fi
|
||||||
if ! test "${cfg.deployFrom}" = ""
|
|
||||||
then
|
# Deploy all webapplications
|
||||||
rm -rf ${cfg.baseDir}/webapps
|
|
||||||
mkdir -p ${cfg.baseDir}/webapps
|
if ! test "${cfg.deployFrom}" = ""
|
||||||
for i in ${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
|
||||||
|
|
||||||
|
# Fix permissions
|
||||||
|
|
||||||
|
chown -R ${cfg.user} ${cfg.baseDir}
|
||||||
|
|
||||||
|
for i in `find ${cfg.baseDir} -type d`
|
||||||
do
|
do
|
||||||
cp -rL $i ${cfg.baseDir}/webapps
|
chmod -v 755 $i
|
||||||
|
done
|
||||||
|
|
||||||
|
for i in `find ${cfg.baseDir} -type f`
|
||||||
|
do
|
||||||
|
chmod -v 644 $i
|
||||||
done
|
done
|
||||||
fi
|
|
||||||
|
|
||||||
# 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
|
|
||||||
|
|
||||||
# Deploy all common libraries
|
# Deploy all common libraries
|
||||||
|
|
||||||
rm -rf ${cfg.baseDir}/lib/*
|
rm -rf ${cfg.baseDir}/lib/*
|
||||||
|
|
||||||
if test "${cfg.commonLibFrom}" = ""
|
if test "${cfg.commonLibFrom}" = ""
|
||||||
then
|
then
|
||||||
commonLibFrom="${pkgs.tomcat6}/lib";
|
commonLibFrom="${pkgs.tomcat6}/lib";
|
||||||
else
|
else
|
||||||
commonLibFrom="${cfg.commonLibFrom}";
|
commonLibFrom="${cfg.commonLibFrom}";
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for i in $commonLibFrom/*.jar
|
for i in $commonLibFrom/*.jar
|
||||||
do
|
do
|
||||||
ln -s $i ${cfg.baseDir}/lib
|
ln -s $i ${cfg.baseDir}/lib
|
||||||
done
|
done
|
||||||
|
|
||||||
# Deploy all shared libraries
|
# Deploy all shared libraries
|
||||||
|
|
||||||
|
if ! test "${cfg.sharedLibFrom}" = ""
|
||||||
|
then
|
||||||
|
rm -f ${cfg.baseDir}/shared/lib
|
||||||
|
ln -s ${cfg.sharedLibFrom} ${cfg.baseDir}/shared/lib
|
||||||
|
fi
|
||||||
|
|
||||||
|
end script
|
||||||
|
|
||||||
if ! test "${cfg.sharedLibFrom}" = ""
|
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}" CATALINA_OPTS="${cfg.catalinaOpts}" ${pkgs.tomcat6}/bin/startup.sh; sleep 1000d'
|
||||||
then
|
|
||||||
rm -f ${cfg.baseDir}/shared/lib
|
stop script
|
||||||
ln -s ${cfg.sharedLibFrom} ${cfg.baseDir}/shared/lib
|
echo "Stopping tomcat..."
|
||||||
fi
|
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
|
||||||
|
end script
|
||||||
end script
|
'';
|
||||||
|
}];
|
||||||
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}" CATALINA_OPTS="${cfg.catalinaOpts}" ${pkgs.tomcat6}/bin/startup.sh; sleep 1000d'
|
};
|
||||||
|
|
||||||
stop script
|
|
||||||
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
|
|
||||||
end script
|
|
||||||
'';
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user