The initial password for the admin account can be found in /var/lib/hydra/.pgpass.
Signed-off-by: Shea Levy <shea@shealevy.com>
ASPNI2AOC553JUKOI6SLF3TF56UPAHINMX2FBSGTQHXSDPN2DCSQC
pass=$(HOME=/root ${pkgs.openssl}/bin/openssl rand -base64 32)
if [ ! -f ${baseDir}/.pgpass ]; then
${config.services.postgresql.package}/bin/psql postgres << EOF
CREATE USER hydra PASSWORD '$pass';
EOF
${config.services.postgresql.package}/bin/createdb -O hydra hydra
cat > ${baseDir}/.pgpass-tmp << EOF
localhost:*:hydra:hydra:$pass
EOF
chown hydra ${baseDir}/.pgpass-tmp
chmod 600 ${baseDir}/.pgpass-tmp
mv ${baseDir}/.pgpass-tmp ${baseDir}/.pgpass
fi
${config.services.postgresql.package}/bin/psql hydra << EOF
BEGIN;
INSERT INTO Users(userName, emailAddress, password) VALUES ('admin', '${cfg.notificationSender}', '$(echo -n $pass | sha1sum | cut -c1-40)');
INSERT INTO UserRoles(userName, role) values('admin', 'admin');
COMMIT;
EOF