add tmpfiles
This commit is contained in:
parent
ed882a6b26
commit
6cf67346c4
2 changed files with 32 additions and 0 deletions
27
database-setup.nu
Normal file
27
database-setup.nu
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
def main [
|
||||||
|
user_config: string
|
||||||
|
database_config: string
|
||||||
|
] {
|
||||||
|
alias psql = ^psql --tuples-only --no-align
|
||||||
|
|
||||||
|
if not ($user_config | path exists) {
|
||||||
|
print $"($user_config) does not exist!"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
if not ($database_config | path exists) {
|
||||||
|
print $"($database_config) does not exist!"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
let users = ($user_config | open)
|
||||||
|
let databases = ($database_config | open)
|
||||||
|
|
||||||
|
$users | debug
|
||||||
|
$databases | debug
|
||||||
|
|
||||||
|
$users | each {
|
||||||
|
|user|
|
||||||
|
let exists = ("SELECT 1 FROM pg_roles WHERE rolname=:'username';" | psql --variable username=$"($user.username)")
|
||||||
|
$exists | debug
|
||||||
|
}
|
||||||
|
}
|
|
@ -427,6 +427,11 @@
|
||||||
useDefaultShell = true;
|
useDefaultShell = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
systemd.tmpfiles.rules = [
|
||||||
|
"d /var/lib/posgresql 0750 postgresql postgresql -"
|
||||||
|
"d /var/lib/posgresql/15 0700 postgresql postgresql -"
|
||||||
|
];
|
||||||
|
|
||||||
systemd.services.postgresql =
|
systemd.services.postgresql =
|
||||||
let
|
let
|
||||||
hbaFile = pkgs.writeTextDir "pg_hba.conf" ''
|
hbaFile = pkgs.writeTextDir "pg_hba.conf" ''
|
||||||
|
|
Loading…
Reference in a new issue