From d8ef63fc73ca169aa6d022c9ed7f10c57a5a5a9a Mon Sep 17 00:00:00 2001 From: Robin Gloster Date: Mon, 17 Oct 2016 12:51:06 +0200 Subject: [PATCH] crowd module: fix OpenID server --- .../services/web-apps/atlassian/crowd.nix | 17 +++++++++++++---- pkgs/servers/atlassian/crowd.nix | 16 +++++++++++++++- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/nixos/modules/services/web-apps/atlassian/crowd.nix b/nixos/modules/services/web-apps/atlassian/crowd.nix index 5e79678023da..ada26f8057ba 100644 --- a/nixos/modules/services/web-apps/atlassian/crowd.nix +++ b/nixos/modules/services/web-apps/atlassian/crowd.nix @@ -6,7 +6,12 @@ let cfg = config.services.crowd; - pkg = pkgs.atlassian-crowd; + pkg = pkgs.atlassian-crowd.override { + home = cfg.home; + port = cfg.listenPort; + proxyUrl = "${cfg.proxy.scheme}://${cfg.proxy.name}:${toString cfg.proxy.port}"; + openidPassword = cfg.openidPassword; + }; in @@ -45,6 +50,11 @@ in description = "Port to listen on."; }; + openidPassword = mkOption { + type = types.str; + description = "Application password for OpenID server."; + }; + catalinaOptions = mkOption { type = types.listOf types.str; default = []; @@ -119,10 +129,10 @@ in }; preStart = '' - mkdir -p ${cfg.home}/{logs,work} + mkdir -p ${cfg.home}/{logs,work,database} mkdir -p /run/atlassian-crowd - ln -sf ${cfg.home}/{work,server.xml} /run/atlassian-crowd + ln -sf ${cfg.home}/{database,work,server.xml} /run/atlassian-crowd chown -R ${cfg.user} ${cfg.home} @@ -134,7 +144,6 @@ in ''; script = "${pkg}/start_crowd.sh"; - #stopScript = "${pkg}/bin/stop_crowd.sh"; serviceConfig = { User = cfg.user; diff --git a/pkgs/servers/atlassian/crowd.nix b/pkgs/servers/atlassian/crowd.nix index d84ddd00882b..05b88cf9cf3b 100644 --- a/pkgs/servers/atlassian/crowd.nix +++ b/pkgs/servers/atlassian/crowd.nix @@ -1,4 +1,5 @@ -{ stdenv, fetchurl, home ? "/var/lib/crowd" }: +{ stdenv, fetchurl, home ? "/var/lib/crowd" +, port ? 8092, proxyUrl ? null, openidPassword ? "WILL_NEVER_BE_SET" }: stdenv.mkDerivation rec { name = "atlassian-crowd-${version}"; @@ -18,9 +19,22 @@ stdenv.mkDerivation rec { rm -rf apache-tomcat/work ln -s /run/atlassian-crowd/work apache-tomcat/work + ln -s /run/atlassian-crowd/database database + substituteInPlace apache-tomcat/bin/startup.sh --replace start run echo "crowd.home=${home}" > crowd-webapp/WEB-INF/classes/crowd-init.properties + substituteInPlace build.properties \ + --replace "openidserver.url=http://localhost:8095/openidserver" \ + "openidserver.url=http://localhost:${toString port}/openidserver" + substituteInPlace crowd-openidserver-webapp/WEB-INF/classes/crowd.properties \ + --replace "http://localhost:8095/" \ + "http://localhost:${toString port}/" + sed -r -i crowd-openidserver-webapp/WEB-INF/classes/crowd.properties \ + -e 's,application.password\s+password,application.password ${openidPassword},' + '' + stdenv.lib.optionalString (proxyUrl != null) '' + sed -i crowd-openidserver-webapp/WEB-INF/classes/crowd.properties \ + -e 's,http://localhost:${toString port}/openidserver,${proxyUrl}/openidserver,' ''; installPhase = ''