diff options
author | ajs124 <git@ajs124.de> | 2023-08-30 00:04:56 +0200 |
---|---|---|
committer | Jörg Thalheim <Mic92@users.noreply.github.com> | 2023-09-09 19:11:54 +0200 |
commit | f8df5ffdfe8e416c320704b908bb92ca58fd5873 (patch) | |
tree | 1416d13069475912d6412f5ea732095e3e44e1ab /nixos/modules/services | |
parent | eda85eb31da861661b2b7dd3a2f03ec69b03f114 (diff) | |
download | nixlib-f8df5ffdfe8e416c320704b908bb92ca58fd5873.tar nixlib-f8df5ffdfe8e416c320704b908bb92ca58fd5873.tar.gz nixlib-f8df5ffdfe8e416c320704b908bb92ca58fd5873.tar.bz2 nixlib-f8df5ffdfe8e416c320704b908bb92ca58fd5873.tar.lz nixlib-f8df5ffdfe8e416c320704b908bb92ca58fd5873.tar.xz nixlib-f8df5ffdfe8e416c320704b908bb92ca58fd5873.tar.zst nixlib-f8df5ffdfe8e416c320704b908bb92ca58fd5873.zip |
nixos/tt-rss: fix and significantly simplify database setup
the schema files referenced in the current preStart are empty. other ones exist, but don't apply cleanly either. calling update.php with --update-schema works for initial setup and updates. if the database schema is already up to date, it's idempotent.
Diffstat (limited to 'nixos/modules/services')
-rw-r--r-- | nixos/modules/services/web-apps/tt-rss.nix | 44 |
1 files changed, 3 insertions, 41 deletions
diff --git a/nixos/modules/services/web-apps/tt-rss.nix b/nixos/modules/services/web-apps/tt-rss.nix index 3102e6a46953..592ab253f7da 100644 --- a/nixos/modules/services/web-apps/tt-rss.nix +++ b/nixos/modules/services/web-apps/tt-rss.nix @@ -595,47 +595,9 @@ let tt-rss = { description = "Tiny Tiny RSS feeds update daemon"; - preStart = let - callSql = e: - if cfg.database.type == "pgsql" then '' - ${optionalString (cfg.database.password != null) "PGPASSWORD=${cfg.database.password}"} \ - ${optionalString (cfg.database.passwordFile != null) "PGPASSWORD=$(cat ${cfg.database.passwordFile})"} \ - ${config.services.postgresql.package}/bin/psql \ - -U ${cfg.database.user} \ - ${optionalString (cfg.database.host != null) "-h ${cfg.database.host} --port ${toString dbPort}"} \ - -c '${e}' \ - ${cfg.database.name}'' - - else if cfg.database.type == "mysql" then '' - echo '${e}' | ${config.services.mysql.package}/bin/mysql \ - -u ${cfg.database.user} \ - ${optionalString (cfg.database.password != null) "-p${cfg.database.password}"} \ - ${optionalString (cfg.database.host != null) "-h ${cfg.database.host} -P ${toString dbPort}"} \ - ${cfg.database.name}'' - - else ""; - - in (optionalString (cfg.database.type == "pgsql") '' - exists=$(${callSql "select count(*) > 0 from pg_tables where tableowner = user"} \ - | tail -n+3 | head -n-2 | sed -e 's/[ \n\t]*//') - - if [ "$exists" == 'f' ]; then - ${callSql "\\i ${pkgs.tt-rss}/schema/ttrss_schema_${cfg.database.type}.sql"} - else - echo 'The database contains some data. Leaving it as it is.' - fi; - '') - - + (optionalString (cfg.database.type == "mysql") '' - exists=$(${callSql "select count(*) > 0 from information_schema.tables where table_schema = schema()"} \ - | tail -n+2 | sed -e 's/[ \n\t]*//') - - if [ "$exists" == '0' ]; then - ${callSql "\\. ${pkgs.tt-rss}/schema/ttrss_schema_${cfg.database.type}.sql"} - else - echo 'The database contains some data. Leaving it as it is.' - fi; - ''); + preStart = '' + ${pkgs.php81}/bin/php ${cfg.root}/www/update.php --update-schema + ''; serviceConfig = { User = "${cfg.user}"; |