mirror of
https://github.com/foo-dogsquared/nixos-config.git
synced 2025-01-31 04:58:01 +00:00
hosts/plover: automate the admin creation on Gitea
This commit is contained in:
parent
fc7ec80933
commit
5e8c65b70e
@ -130,11 +130,25 @@ in
|
|||||||
|
|
||||||
# Gitea service module will have to set up certain things first which is
|
# Gitea service module will have to set up certain things first which is
|
||||||
# why we have to go first.
|
# why we have to go first.
|
||||||
preStart = lib.mkBefore ''
|
preStart = let
|
||||||
# Setting up the appropriate schema for PostgreSQL secure schema usage.
|
giteaBin = "${lib.getBin config.services.gitea.package}/bin/gitea";
|
||||||
psql -tAc "SELECT 1 FROM information_schema.schemata WHERE schema_name='${giteaDatabaseUser}';" \
|
giteaAdminUsername = lib.escapeShellArg "foodogsquared";
|
||||||
grep -q 1 || psql -tAc "CREATE SCHEMA IF NOT EXISTS AUTHORIZATION ${giteaDatabaseUser};"
|
in
|
||||||
'';
|
lib.mkMerge [
|
||||||
|
(lib.mkBefore ''
|
||||||
|
# Setting up the appropriate schema for PostgreSQL secure schema usage.
|
||||||
|
psql -tAc "SELECT 1 FROM information_schema.schemata WHERE schema_name='${giteaDatabaseUser}';" \
|
||||||
|
grep -q 1 || psql -tAc "CREATE SCHEMA IF NOT EXISTS AUTHORIZATION ${giteaDatabaseUser};"
|
||||||
|
'')
|
||||||
|
|
||||||
|
(lib.mkAfter ''
|
||||||
|
# Setting up the administrator account automated.
|
||||||
|
${giteaBin} admin user list --admin | grep -q ${giteaAdminUsername} \
|
||||||
|
|| ${giteaBin} admin user create \
|
||||||
|
--username ${giteaAdminUsername} --email foodogsquared@${config.networking.domain} \
|
||||||
|
--random-password --random-password-length 76 --admin
|
||||||
|
'')
|
||||||
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
# Attaching it altogether with the reverse proxy of choice.
|
# Attaching it altogether with the reverse proxy of choice.
|
||||||
|
Loading…
Reference in New Issue
Block a user