Merge pull request #268187 from imincik/geoserver-fix-data-dir

This commit is contained in:
Artturi 2023-11-25 16:22:31 +02:00 committed by GitHub
commit 4706651a16
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 62 additions and 2 deletions

View file

@ -321,6 +321,7 @@ in {
mimir = handleTest ./mimir.nix {};
garage = handleTest ./garage {};
gemstash = handleTest ./gemstash.nix {};
geoserver = runTest ./geoserver.nix;
gerrit = handleTest ./gerrit.nix {};
geth = handleTest ./geth.nix {};
ghostunnel = handleTest ./ghostunnel.nix {};

24
nixos/tests/geoserver.nix Normal file
View file

@ -0,0 +1,24 @@
{ pkgs, lib, ... }: {
name = "geoserver";
meta = {
maintainers = with lib; [ teams.geospatial.members ];
};
nodes = {
machine = { pkgs, ... }: {
virtualisation.diskSize = 2 * 1024;
environment.systemPackages = [ pkgs.geoserver ];
};
};
testScript = ''
start_all()
machine.execute("${pkgs.geoserver}/bin/geoserver-startup > /dev/null 2>&1 &")
machine.wait_until_succeeds("curl --fail --connect-timeout 2 http://localhost:8080/geoserver", timeout=60)
machine.succeed("curl --fail --connect-timeout 2 http://localhost:8080/geoserver/ows?service=WMS&version=1.3.0&request=GetCapabilities")
'';
}

View file

@ -0,0 +1,18 @@
--- a/bin/startup.sh
+++ b/bin/startup.sh
@@ -66,12 +66,9 @@ fi
#Find the configuration directory: GEOSERVER_DATA_DIR
if [ -z "${GEOSERVER_DATA_DIR:-}" ]; then
- if [ -r "${GEOSERVER_HOME}/data_dir" ]; then
- export GEOSERVER_DATA_DIR="${GEOSERVER_HOME}/data_dir"
- else
- echo "No GEOSERVER_DATA_DIR found, using application defaults"
- GEOSERVER_DATA_DIR=""
- fi
+ echo "GEOSERVER_DATA_DIR is not provided. Using $(pwd)/geoserver/data_dir directory"
+ mkdir -p "$(pwd)"/geoserver/data_dir
+ GEOSERVER_DATA_DIR="$(pwd)/geoserver/data_dir"
fi
cd "${GEOSERVER_HOME}" || exit 1

View file

@ -1,4 +1,12 @@
{ lib, stdenv, fetchurl, unzip, jre, makeWrapper }:
{ lib
, fetchurl
, makeWrapper
, nixosTests
, stdenv
, jre
, unzip
}:
stdenv.mkDerivation rec {
pname = "geoserver";
@ -9,6 +17,11 @@ stdenv.mkDerivation rec {
sha256 = "sha256-xX1rAONMh5XSWGPXkVMemAvG34DDNmu2018HsTvY7G0=";
};
patches = [
# set GEOSERVER_DATA_DIR to current working directory if not provided
./data-dir.patch
];
sourceRoot = ".";
nativeBuildInputs = [ unzip makeWrapper ];
@ -27,12 +40,16 @@ stdenv.mkDerivation rec {
runHook postInstall
'';
passthru = {
tests.geoserver = nixosTests.geoserver;
};
meta = with lib; {
description = "Open source server for sharing geospatial data";
homepage = "https://geoserver.org/";
sourceProvenance = with sourceTypes; [ binaryBytecode ];
license = licenses.gpl2Plus;
maintainers = with maintainers; [ sikmir ];
maintainers = teams.geospatial.members;
platforms = platforms.all;
};
}