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
|
||||
# why we have to go first.
|
||||
preStart = 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};"
|
||||
'';
|
||||
preStart = let
|
||||
giteaBin = "${lib.getBin config.services.gitea.package}/bin/gitea";
|
||||
giteaAdminUsername = lib.escapeShellArg "foodogsquared";
|
||||
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.
|
||||
|
Loading…
Reference in New Issue
Block a user