From 94ec94e32d730247aa22b68f4540ead05780e6c4 Mon Sep 17 00:00:00 2001 From: Chris Vogel Date: Wed, 8 May 2024 16:14:04 +0200 Subject: [PATCH] corrections to backup/restore --- doc/POST_INSTALL.md | 13 +++++++++++++ doc/PRE_INSTALL.md | 12 ++++++------ scripts/_common.sh | 17 +++++++++++++++++ scripts/backup | 4 ++-- scripts/install | 10 ++++++---- scripts/restore | 13 +++++++------ scripts/upgrade | 7 +++++-- 7 files changed, 56 insertions(+), 20 deletions(-) create mode 100644 doc/POST_INSTALL.md diff --git a/doc/POST_INSTALL.md b/doc/POST_INSTALL.md new file mode 100644 index 0000000..9dd1c39 --- /dev/null +++ b/doc/POST_INSTALL.md @@ -0,0 +1,13 @@ +## finishing setup + +To finish your flohmarkt setup you'll need to open its setup URL. + +You can find the setup URL in the logfile __FLOHMARKT_LOGFILE__ if you look for entries like this: + +``` +2024-05-06 16:30:24 Flohmarkt is not initialized yet. Please go to +2024-05-06 16:30:24 https://YOUR_URL/setup/SECRET +2024-05-06 16:30:24 in order to complete the setup process +``` + +(YOUR_URL will reflect the DOMAIN/PATH you chose for installation and SECRET is a random string) diff --git a/doc/PRE_INSTALL.md b/doc/PRE_INSTALL.md index 91c309b..562a666 100644 --- a/doc/PRE_INSTALL.md +++ b/doc/PRE_INSTALL.md @@ -1,17 +1,17 @@ -## Warning: Exclusive use of couchdb +## use of couchdb -flohmarkt expects to install CouchDB from the Apache repository for its own, exclusive use. Installation might break already existing installs of CouchDB. +flohmarkt expects to install CouchDB from the Apache repository for its use. Installation of flohmarkt might break already existing installs of CouchDB. **flohmarkt will probably not install if you're already running an instance of a couchdb** https://codeberg.org/flohmarkt/flohmarkt_ynh/src/commit/7721103bac61787f31a4b2f2ae695c65d4f26fc9/scripts/install#L9 https://codeberg.org/ChriChri/flohmarkt_ynh/issues/9 -## Exclusive use of (sub)domain +## multiple flohmarkt on the same subdomain -flohmarkt expects to bei installed on its own (sub)domain. +The installation will allow you to **test** this. The feature is not well tested, yet, and installing multiple productive flohmarkts in the same domain might not work on the fediverse. -https://codeberg.org/ChriChri/flohmarkt_ynh/issues/4 . +Feedback is more than welcome! ## No integration in yunohost user database" @@ -19,7 +19,7 @@ flohmarkt mainanins its own user database in CouchDB. Users have to register to https://codeberg.org/ChriChri/flohmarkt_ynh/issues/5 . -## removing after installation +## removing **Warning:** This might break any existing installation of couchdb (there's an couchdb app to install just couchdb and expose its port via nginx reverse-proxy and possibly other software installing a couchdb). This could happen if you installed the couchdb app after you installed flohmarkt. diff --git a/scripts/_common.sh b/scripts/_common.sh index d0c8c96..0d5b70d 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -46,6 +46,23 @@ flohmarkt_old_service="flohmarkt" # PERSONAL HELPERS #================================================= +# set file permissions and owner for installation +flohmarkt_ynh_set_permission() { + # install dir - only root needs to write and $app reads + chown root:$app -R "$flohmarkt_install" + chmod g-w,o-rwx -R "$flohmarkt_install" +} + +flohmarkt_ynh_start_service() { + ynh_systemd_action --service_name=$flohmarkt_filename --action="start" \ + --line_match='INFO: *Application startup complete.' --log_path="$flohmarkt_logfile" \ + --timeout=30 +} + +flohmarkt_ynh_stop_service() { + ynh_systemd_action --service_name=$app --action="stop" +} + # create venv flohmarkt_ynh_create_venv() { python3 -m venv --without-pip "$flohmarkt_venv_dir" diff --git a/scripts/backup b/scripts/backup index f00fac9..856f3b5 100755 --- a/scripts/backup +++ b/scripts/backup @@ -11,7 +11,7 @@ ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf" ynh_backup --src_path="/etc/logrotate.d/$app" ynh_backup --src_path="/opt/couchdb/etc/local.d/05-flohmarkt.ini" ynh_backup --src_path="/etc/systemd/system/$flohmarkt_filename.service" -ynh_backup --src_path="${flohmarkt_logfile}*" +ynh_backup --src_path="${flohmarkt_log_dir}" # for the following backups we'll want to stop flohmarkt and couchdb # to guarentee a consistant state @@ -34,6 +34,6 @@ ynh_backup --src_path="/var/lib/couchdb" ynh_print_info --message="...done. Starting couchdb and flohmarkt." systemctl start couchdb -yunohost service start flohmarkt +flohmarkt_ynh_start_service ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/install b/scripts/install index a923a99..971c760 100755 --- a/scripts/install +++ b/scripts/install @@ -110,12 +110,14 @@ ynh_add_systemd_config --service=$flohmarkt_filename # integrate into yunohost ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 yunohost service add $flohmarkt_filename --description="A decentral federated small advertisement platform" --log="$flohmarkt_logfile" + # logfile contains possibly the secret setup URL mkdir -m755 -p "$flohmarkt_log_dir" touch "$flohmarkt_logfile" chmod 640 "$flohmarkt_logfile" -# start service -ynh_systemd_action --service_name=$flohmarkt_filename --action="start" --line_match='INFO: *Application startup complete.' --log_path="$flohmarkt_logfile" --timeout=30 + +# set file permissions for install dir +flohmarkt_ynh_set_permission # SETUP FAIL2BAN ynh_script_progression --message="Configuring Fail2Ban..." --weight=3 @@ -126,7 +128,7 @@ ynh_add_fail2ban_config --logpath="$flohmarkt_logfile" --failregex='INFO: +