From fdc07530c7571897b9ef2a80cd4c26fa96ec9d85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Tue, 3 Oct 2023 11:27:25 +0200 Subject: [PATCH] env --- conf/.env | 4 ++++ conf/systemd.service | 3 +-- manifest.toml | 6 +++++- scripts/backup | 7 +++++++ scripts/restore | 7 +++++++ 5 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 conf/.env diff --git a/conf/.env b/conf/.env new file mode 100644 index 0000000..84a4ae8 --- /dev/null +++ b/conf/.env @@ -0,0 +1,4 @@ +SHIORI_WEBROOT=__PATH__ +SHIORI_PORT__PORT__ +SHIORI_DIR=__DATA_DIR__ +SHIORI_DATABASE_URL="postgres://__DB_USER__:__DB_PWD__@hostname/__DB_NAME__?sslmode=verify-full" \ No newline at end of file diff --git a/conf/systemd.service b/conf/systemd.service index 2df65bb..62ed20f 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -8,9 +8,8 @@ Type=simple User=__APP__ Group=__APP__ WorkingDirectory=__INSTALL_DIR__/ -ExecStart=__INSTALL_DIR__/shiori serve --port __PORT__ --webroot __PATH__ +ExecStart=__INSTALL_DIR__/shiori serve Restart=always -Environment="SHIORI_DIR=__DATA_DIR__" [Install] WantedBy=multi-user.target diff --git a/manifest.toml b/manifest.toml index 02d6ac0..a54bc17 100644 --- a/manifest.toml +++ b/manifest.toml @@ -69,4 +69,8 @@ ram.runtime = "50M" api.auth_header = false [resources.apt] - packages = "sqlite3" + packages = "postgresql" + + [resources.database] + type = "postgresql" + \ No newline at end of file diff --git a/scripts/backup b/scripts/backup index 737146f..810b96b 100755 --- a/scripts/backup +++ b/scripts/backup @@ -41,6 +41,13 @@ ynh_backup --src_path="/etc/logrotate.d/$app" ynh_backup --src_path="/etc/systemd/system/$app.service" +#================================================= +# BACKUP THE PostgreSQL DATABASE +#================================================= +ynh_print_info --message="Backing up the PostgreSQL database..." + +ynh_psql_dump_db --database="$db_name" > db.sql + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index 4485474..6db7d58 100755 --- a/scripts/restore +++ b/scripts/restore @@ -30,6 +30,13 @@ ynh_restore_file --origin_path="$data_dir" --not_mandatory chown -R $app:www-data "$data_dir" +#================================================= +# RESTORE THE PostgreSQL DATABASE +#================================================= +ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1 + +ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql + #================================================= # RESTORE SYSTEM CONFIGURATIONS #=================================================