dixie: use script attr for dropsonde-pg-setup (ExecStart heredoc+bash path broken)
This commit is contained in:
+13
-14
@@ -154,6 +154,7 @@ in
|
||||
description = "dropsonde2: set dropsonde role password + create extensions";
|
||||
wants = [ "postgresql-setup.service" ];
|
||||
after = [ "postgresql-setup.service" "postgresql.service" ];
|
||||
path = [ config.services.postgresql.package ];
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
RemainAfterExit = true;
|
||||
@@ -162,21 +163,19 @@ in
|
||||
Restart = "on-failure";
|
||||
RestartSec = "10s";
|
||||
LoadCredential = [ "dropsonde-pg-password:/root/dropsonde-pg" ];
|
||||
ExecStart = ''${pkgs.coreutils}/bin/bash <<'BASH'
|
||||
set -euo pipefail
|
||||
pw=$(cat "$CREDENTIALS_DIRECTORY/dropsonde-pg-password")
|
||||
psql -v ON_ERROR_STOP=1 -v pw="$pw" -d postgres <<'SQL'
|
||||
ALTER ROLE dropsonde WITH LOGIN PASSWORD :'pw';
|
||||
SQL
|
||||
psql -v ON_ERROR_STOP=1 -d dropsonde <<'SQL'
|
||||
CREATE EXTENSION IF NOT EXISTS timescaledb;
|
||||
CREATE EXTENSION IF NOT EXISTS postgis;
|
||||
CREATE EXTENSION IF NOT EXISTS h3;
|
||||
CREATE EXTENSION IF NOT EXISTS h3_postgis CASCADE;
|
||||
SQL
|
||||
BASH
|
||||
'';
|
||||
};
|
||||
script = ''
|
||||
pw=$(cat "$CREDENTIALS_DIRECTORY/dropsonde-pg-password")
|
||||
psql -v ON_ERROR_STOP=1 -v pw="$pw" -d postgres <<'SQL'
|
||||
ALTER ROLE dropsonde WITH LOGIN PASSWORD :'pw';
|
||||
SQL
|
||||
psql -v ON_ERROR_STOP=1 -d dropsonde <<'SQL'
|
||||
CREATE EXTENSION IF NOT EXISTS timescaledb;
|
||||
CREATE EXTENSION IF NOT EXISTS postgis;
|
||||
CREATE EXTENSION IF NOT EXISTS h3;
|
||||
CREATE EXTENSION IF NOT EXISTS h3_postgis CASCADE;
|
||||
SQL
|
||||
'';
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user