nixos/traccar: update module defaults (#459267)
This commit is contained in:
@@ -35,8 +35,7 @@ let
|
|||||||
user = "sa";
|
user = "sa";
|
||||||
};
|
};
|
||||||
logger.console = "true";
|
logger.console = "true";
|
||||||
media.path = "${stateDirectory}/media";
|
web.override = "${stateDirectory}/override";
|
||||||
templates.root = "${stateDirectory}/templates";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
in
|
in
|
||||||
@@ -95,11 +94,9 @@ in
|
|||||||
wants = [ "network-online.target" ];
|
wants = [ "network-online.target" ];
|
||||||
|
|
||||||
preStart = ''
|
preStart = ''
|
||||||
# Copy new templates into our state directory.
|
|
||||||
cp -a --update=none ${pkgs.traccar}/templates ${stateDirectory}
|
|
||||||
test -f '${configFilePath}' && rm -f '${configFilePath}'
|
test -f '${configFilePath}' && rm -f '${configFilePath}'
|
||||||
|
|
||||||
# Substitute the configFile from Envvars read from EnvironmentFile
|
# Perform envvars substition read from environmentFile
|
||||||
old_umask=$(umask)
|
old_umask=$(umask)
|
||||||
umask 0177
|
umask 0177
|
||||||
${lib.getExe pkgs.envsubst} \
|
${lib.getExe pkgs.envsubst} \
|
||||||
@@ -110,6 +107,7 @@ in
|
|||||||
|
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
DynamicUser = true;
|
DynamicUser = true;
|
||||||
|
WorkingDirectory = "${pkgs.traccar}";
|
||||||
EnvironmentFile = lib.mkIf (cfg.environmentFile != null) cfg.environmentFile;
|
EnvironmentFile = lib.mkIf (cfg.environmentFile != null) cfg.environmentFile;
|
||||||
ExecStart = "${lib.getExe pkgs.traccar} ${configFilePath}";
|
ExecStart = "${lib.getExe pkgs.traccar} ${configFilePath}";
|
||||||
LockPersonality = true;
|
LockPersonality = true;
|
||||||
@@ -132,11 +130,6 @@ in
|
|||||||
StateDirectory = "traccar";
|
StateDirectory = "traccar";
|
||||||
SuccessExitStatus = 143;
|
SuccessExitStatus = 143;
|
||||||
Type = "simple";
|
Type = "simple";
|
||||||
# Set the working directory to traccar's package.
|
|
||||||
# Traccar only searches for the DB migrations relative to it's WorkingDirectory and nothing worked to
|
|
||||||
# work around this. To avoid copying the migrations over to the state directory, we use the package as
|
|
||||||
# WorkingDirectory.
|
|
||||||
WorkingDirectory = "${pkgs.traccar}";
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1557,6 +1557,7 @@ in
|
|||||||
tor = runTest ./tor.nix;
|
tor = runTest ./tor.nix;
|
||||||
tpm-ek = handleTest ./tpm-ek { };
|
tpm-ek = handleTest ./tpm-ek { };
|
||||||
tpm2 = runTest ./tpm2.nix;
|
tpm2 = runTest ./tpm2.nix;
|
||||||
|
traccar = runTest ./traccar.nix;
|
||||||
# tracee requires bpf
|
# tracee requires bpf
|
||||||
tracee = handleTestOn [ "x86_64-linux" ] ./tracee.nix { };
|
tracee = handleTestOn [ "x86_64-linux" ] ./tracee.nix { };
|
||||||
traefik = runTestOn [ "aarch64-linux" "x86_64-linux" ] ./traefik.nix;
|
traefik = runTestOn [ "aarch64-linux" "x86_64-linux" ] ./traefik.nix;
|
||||||
|
|||||||
51
nixos/tests/traccar.nix
Normal file
51
nixos/tests/traccar.nix
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
{
|
||||||
|
pkgs,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
{
|
||||||
|
name = "traccar";
|
||||||
|
meta = {
|
||||||
|
maintainers = with lib.maintainers; [ frederictobiasc ];
|
||||||
|
};
|
||||||
|
nodes.machine = {
|
||||||
|
services.traccar = {
|
||||||
|
enable = true;
|
||||||
|
settings.mail.smtp.host = "$SMTP_HOST";
|
||||||
|
environmentFile = pkgs.writeText "traccar.env" ''
|
||||||
|
SMTP_HOST=smtp.example.com
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
testScript = ''
|
||||||
|
machine.wait_for_unit("traccar.service")
|
||||||
|
|
||||||
|
# Check that environment variables were substituted
|
||||||
|
t.assertIn("smtp.example.com", machine.succeed("cat /var/lib/traccar/config.xml"), "environment substitution failed")
|
||||||
|
|
||||||
|
machine.wait_for_open_port(8082)
|
||||||
|
|
||||||
|
# Check that we get the traccar login page
|
||||||
|
t.assertIn("Traccar", machine.wait_until_succeeds("curl -sf http://localhost:8082/"), "Traccar frontend seems unreachable")
|
||||||
|
|
||||||
|
# Register the first admin user
|
||||||
|
register_data = """
|
||||||
|
{
|
||||||
|
"email": "admin@example.com",
|
||||||
|
"name": "admin",
|
||||||
|
"password": "admin123"
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
t.assertIn(
|
||||||
|
"\"administrator\":true",
|
||||||
|
machine.succeed(
|
||||||
|
"curl -s -X POST "
|
||||||
|
"-H 'Content-Type: application/json' "
|
||||||
|
f"-d '{register_data}' "
|
||||||
|
"http://localhost:8082/api/users"
|
||||||
|
),
|
||||||
|
"Unexpected registration response"
|
||||||
|
)
|
||||||
|
'';
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user