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.

Changed files
+6 -3
nixos
modules
services
monitoring
tests
+6
nixos/modules/services/monitoring/librenms.nix
···
${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
···
if [[ $OLD_VERSION != "${package.version}" ]]; then
${artisanWrapper}/bin/librenms-artisan migrate --force --no-interaction
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
-3
nixos/tests/librenms.nix
···
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