miniflux: Get credentials from dbconfig-common directly

Fixes: #2562

Newer miniflux package does not create a separate file called
/etc/miniflux/database. Instead it write the database URL directly into
/etc/miniflux/miniflux.conf. It is easier to create the database settings from
dbconfig-common that to read them from miniflux.conf.

Signed-off-by: Frederico Gomes <fredericojfgomes@gmail.com>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
Frederico Gomes 2026-02-26 17:41:35 +00:00 committed by Sunil Mohan Adapa
parent 9a524b331b
commit af6d1d9a4c
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2

View File

@ -5,13 +5,12 @@ import json
import os
import pathlib
from typing import Tuple
from urllib.parse import urlparse
import pexpect
from plinth import action_utils
from plinth.actions import privileged, secret_str
from plinth.db import postgres
from plinth.db import postgres, dbconfig
from plinth.utils import is_non_empty_file
STATIC_SETTINGS = {
@ -21,7 +20,7 @@ STATIC_SETTINGS = {
}
ENV_VARS_FILE = '/etc/miniflux/freedombox.conf'
DATABASE_FILE = '/etc/miniflux/database'
DBCONFIG_PATH = '/etc/dbconfig-common/miniflux.conf'
DB_BACKUP_FILE = '/var/lib/plinth/backups-data/miniflux-database.sql'
@ -117,28 +116,16 @@ def uninstall():
])
def _get_database_config():
"""Retrieve database credentials."""
db_connection_string = pathlib.Path(DATABASE_FILE).read_text().strip()
parsed_url = urlparse(db_connection_string)
return {
'user': parsed_url.username,
'password': parsed_url.password,
'database': parsed_url.path.lstrip('/'),
'host': parsed_url.hostname,
}
@privileged
def dump_database():
"""Dump database to file."""
config = _get_database_config()
config = dbconfig.get_credentials(DBCONFIG_PATH)
postgres.dump_database(DB_BACKUP_FILE, config['database'])
@privileged
def restore_database():
"""Restore database from file."""
config = _get_database_config()
config = dbconfig.get_credentials(DBCONFIG_PATH)
postgres.restore_database(DB_BACKUP_FILE, config['database'],
config['user'], config['password'])