diff options
author | Pavel Goran <me@pvgoran.name> | 2018-10-29 18:26:22 +0700 |
---|---|---|
committer | Pavel Goran <me@pvgoran.name> | 2018-10-29 18:26:22 +0700 |
commit | a57bbf4e6319ca5c9a22968fc74845d29d3c6f80 (patch) | |
tree | 9a280ea284958ecfe538b4a69ec9a97936b562d1 /nixos/modules/services/web-servers/tomcat.nix | |
parent | 641ef3ab237b0467c4aa7778d7c3095be671d95f (diff) | |
download | nixpkgs-a57bbf4e6319ca5c9a22968fc74845d29d3c6f80.tar nixpkgs-a57bbf4e6319ca5c9a22968fc74845d29d3c6f80.tar.gz nixpkgs-a57bbf4e6319ca5c9a22968fc74845d29d3c6f80.tar.bz2 nixpkgs-a57bbf4e6319ca5c9a22968fc74845d29d3c6f80.tar.lz nixpkgs-a57bbf4e6319ca5c9a22968fc74845d29d3c6f80.tar.xz nixpkgs-a57bbf4e6319ca5c9a22968fc74845d29d3c6f80.tar.zst nixpkgs-a57bbf4e6319ca5c9a22968fc74845d29d3c6f80.zip |
nixos/tomcat: add purifyOnStart option
With this option enabled, before creating file/directories/symlinks in baseDir according to configuration, old occurences of them are removed. This prevents remainders of an old configuration (libraries, webapps, you name it) from persisting after activating a new configuration.
Diffstat (limited to 'nixos/modules/services/web-servers/tomcat.nix')
-rw-r--r-- | nixos/modules/services/web-servers/tomcat.nix | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/nixos/modules/services/web-servers/tomcat.nix b/nixos/modules/services/web-servers/tomcat.nix index be54e9255c7..68261c50324 100644 --- a/nixos/modules/services/web-servers/tomcat.nix +++ b/nixos/modules/services/web-servers/tomcat.nix @@ -31,10 +31,26 @@ in ''; }; + purifyOnStart = mkOption { + type = types.bool; + default = false; + description = '' + On startup, the `baseDir` directory is populated with various files, + subdirectories and symlinks. If this option is enabled, these items + (except for the `logs` and `work` subdirectories) are first removed. + This prevents interference from remainders of an old configuration + (libraries, webapps, etc.), so it's recommended to enable this option. + ''; + }; + baseDir = mkOption { type = lib.types.path; default = "/var/tomcat"; - description = "Location where Tomcat stores configuration files, webapplications and logfiles"; + description = '' + Location where Tomcat stores configuration files, web applications + and logfiles. Note that it is partially cleared on each service startup + if `purifyOnStart` is enabled. + ''; }; logDirs = mkOption { @@ -197,6 +213,15 @@ in after = [ "network.target" ]; preStart = '' + ${lib.optionalString cfg.purifyOnStart '' + # Delete most directories/symlinks we create from the existing base directory, + # to get rid of remainders of an old configuration. + # The list of directories to delete is taken from the "mkdir" command below, + # excluding "logs" (because logs are valuable) and "work" (because normally + # session files are there), and additionally including "bin". + rm -rf ${cfg.baseDir}/{conf,virtualhosts,temp,lib,shared/lib,webapps,bin} + ''} + # Create the base directory mkdir -p \ ${cfg.baseDir}/{conf,virtualhosts,logs,temp,lib,shared/lib,webapps,work} |