nixos/librenms: seed database in module, not only in test

To properly use librenms and create a user, you need the seeded roles
like admin.
This commit is contained in:
Sandro Jäckel 2025-05-12 21:25:47 +02:00 committed by Jennifer Graul
parent 8f797af34d
commit 314cfdddb5
No known key found for this signature in database
GPG key ID: C665F6EC9D4634F8
2 changed files with 6 additions and 3 deletions

View file

@ -596,7 +596,9 @@ in
${pkgs.envsubst}/bin/envsubst -i ${configJson} -o ${cfg.dataDir}/config.json
export PHPRC=${phpIni}
INIT=false
if [[ ! -s ${cfg.dataDir}/.env ]]; then
INIT=true
# init .env file
echo "APP_KEY=" > ${cfg.dataDir}/.env
${artisanWrapper}/bin/librenms-artisan key:generate --ansi
@ -655,6 +657,10 @@ in
echo "${package.version}" > ${cfg.dataDir}/version
fi
if [[ $INIT == "true" ]]; then
${artisanWrapper}/bin/librenms-artisan db:seed --force --no-interaction
fi
# regenerate cache if package has changed
if [[ $OLD_PACKAGE != "${package}" ]]; then
${artisanWrapper}/bin/librenms-artisan view:clear

View file

@ -50,9 +50,6 @@ in
API_USER_NAME=api
API_TOKEN=${api_token} # random md5 hash
# seeding database to get the admin roles
${pkgs.librenms}/artisan db:seed --force --no-interaction
# we don't need to know the password, it just has to exist
API_USER_PASS=$(${pkgs.pwgen}/bin/pwgen -s 64 1)
${pkgs.librenms}/artisan user:add $API_USER_NAME -r admin -p $API_USER_PASS