1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/flohmarkt_ynh.git synced 2024-09-03 18:36:30 +02:00

corrections to backup/restore

This commit is contained in:
Chris Vogel 2024-05-08 16:14:04 +02:00
parent 6287cd7725
commit 94ec94e32d
7 changed files with 56 additions and 20 deletions

13
doc/POST_INSTALL.md Normal file
View file

@ -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)

View file

@ -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** **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/flohmarkt/flohmarkt_ynh/src/commit/7721103bac61787f31a4b2f2ae695c65d4f26fc9/scripts/install#L9
https://codeberg.org/ChriChri/flohmarkt_ynh/issues/9 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" ## 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 . 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. **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.

View file

@ -46,6 +46,23 @@ flohmarkt_old_service="flohmarkt"
# PERSONAL HELPERS # 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 # create venv
flohmarkt_ynh_create_venv() { flohmarkt_ynh_create_venv() {
python3 -m venv --without-pip "$flohmarkt_venv_dir" python3 -m venv --without-pip "$flohmarkt_venv_dir"

View file

@ -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="/etc/logrotate.d/$app"
ynh_backup --src_path="/opt/couchdb/etc/local.d/05-flohmarkt.ini" 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="/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 # for the following backups we'll want to stop flohmarkt and couchdb
# to guarentee a consistant state # 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." ynh_print_info --message="...done. Starting couchdb and flohmarkt."
systemctl start couchdb 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)." ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

View file

@ -110,12 +110,14 @@ ynh_add_systemd_config --service=$flohmarkt_filename
# integrate into yunohost # integrate into yunohost
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 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" yunohost service add $flohmarkt_filename --description="A decentral federated small advertisement platform" --log="$flohmarkt_logfile"
# logfile contains possibly the secret setup URL # logfile contains possibly the secret setup URL
mkdir -m755 -p "$flohmarkt_log_dir" mkdir -m755 -p "$flohmarkt_log_dir"
touch "$flohmarkt_logfile" touch "$flohmarkt_logfile"
chmod 640 "$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 # SETUP FAIL2BAN
ynh_script_progression --message="Configuring Fail2Ban..." --weight=3 ynh_script_progression --message="Configuring Fail2Ban..." --weight=3
@ -126,7 +128,7 @@ ynh_add_fail2ban_config --logpath="$flohmarkt_logfile" --failregex='INFO: +<HOST
ln -s "$flohmarkt_install" "$flohmarkt_sym_install" ln -s "$flohmarkt_install" "$flohmarkt_sym_install"
ln -s "$flohmarkt_data_dir" "$flohmarkt_sym_data_dir" ln -s "$flohmarkt_data_dir" "$flohmarkt_sym_data_dir"
# debug # start service
env flohmarkt_ynh_start_service
ynh_script_progression --message="Installation of $id completed" --last ynh_script_progression --message="Installation of $id completed" --last

View file

@ -5,6 +5,7 @@ source /usr/share/yunohost/helpers
# restore couchdb directory # restore couchdb directory
ynh_script_progression --message="Restoring couchdb directory..." --weight=1 ynh_script_progression --message="Restoring couchdb directory..." --weight=1
# argh, need this for a single database
ynh_restore_file --origin_path="/var/lib/couchdb" ynh_restore_file --origin_path="/var/lib/couchdb"
# reinstall couchdb # reinstall couchdb
@ -42,11 +43,11 @@ systemctl status couchdb
# RESTORE THE APP MAIN DIR # RESTORE THE APP MAIN DIR
ynh_script_progression --message="Restoring the app main directory..." --weight=10 ynh_script_progression --message="Restoring the app main directory..." --weight=10
ynh_restore_file --origin_path="$install_dir" ynh_restore_file --origin_path="$flohmarkt_install"
# RESTORE THE DATA DIRECTORY # RESTORE THE DATA DIRECTORY
ynh_script_progression --message="Restoring the data directory..." --weight=1 ynh_script_progression --message="Restoring the data directory..." --weight=1
ynh_restore_file --origin_path="$data_dir" --not_mandatory ynh_restore_file --origin_path="$flohmarkt_data_dir=" --not_mandatory
mkdir -p $data_dir mkdir -p $data_dir
# restore logfiles # restore logfiles
@ -64,8 +65,8 @@ chmod 640 "$flohmarkt_logfile"
# RESTORE FAIL2BAN CONFIGURATION # RESTORE FAIL2BAN CONFIGURATION
ynh_script_progression --message="Restoring the Fail2Ban configuration..." --weight=2 ynh_script_progression --message="Restoring the Fail2Ban configuration..." --weight=2
ynh_restore_file --origin_path="/etc/fail2ban/jail.d/$flohmarkt_logfile.conf" ynh_restore_file --origin_path="/etc/fail2ban/jail.d/$app.conf"
ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$flohmarkt_logfile.conf" ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf"
ynh_systemd_action --action=restart --service_name=fail2ban ynh_systemd_action --action=restart --service_name=fail2ban
# RESTORE THE NGINX CONFIGURATION # RESTORE THE NGINX CONFIGURATION
@ -79,9 +80,9 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app"
# restore flohmarkt systemd service and integrate service into yunohost # restore flohmarkt systemd service and integrate service into yunohost
ynh_script_progression --message="Restoring flohmarkt.service and integrating service into YunoHost..." --weight=1 ynh_script_progression --message="Restoring flohmarkt.service and integrating service into YunoHost..." --weight=1
ynh_restore_file --origin_path="/etc/systemd/system/$flohmarkt_filename.service" ynh_restore_file --origin_path="/etc/systemd/system/$flohmarkt_filename.service"
ynh_systemd_action --action=enable ynh_systemd_action --action=enable --service_name=$flohmarkt_filename
yunohost service add $app --description="A decentral federated small advertisement platform" --log="$flohmarkt_logfile" yunohost service add $app --description="A decentral federated small advertisement platform" --log="$flohmarkt_logfile"
ynh_systemd_action --action=start --line_match="INFO: Application startup complete." flohmarkt_ynh_start_service
# RELOAD NGINX # RELOAD NGINX
ynh_script_progression --message="Reloading NGINX web server..." --weight=1 ynh_script_progression --message="Reloading NGINX web server..." --weight=1

View file

@ -15,7 +15,7 @@ upgrade_type=$(ynh_check_app_version_changed)
ynh_script_progression --message="Stopping flohmarkt and CouchDB..." --weight=5 ynh_script_progression --message="Stopping flohmarkt and CouchDB..." --weight=5
# stop flohmarkt # stop flohmarkt
ynh_systemd_action --service_name=$app --action="stop" flohmarkt_ynh_stop_service
# stop couchdb # stop couchdb
ynh_systemd_action --service_name=couchdb --action="stop" ynh_systemd_action --service_name=couchdb --action="stop"
@ -82,6 +82,9 @@ ynh_script_progression --message="Upgrading flohmarkt couchdb..." --weight=10
timeout 45 python3 initialize_couchdb.py $password_couchdb_admin $password_couchdb_flohmarkt timeout 45 python3 initialize_couchdb.py $password_couchdb_admin $password_couchdb_flohmarkt
) )
# set file permissions for install dir
flohmarkt_ynh_set_permission
# systemd service upgrade # systemd service upgrade
ynh_script_progression --message="Upgrading flohmarkt systemd service..." --weight=1 ynh_script_progression --message="Upgrading flohmarkt systemd service..." --weight=1
ynh_add_systemd_config --service=$flohmarkt_filename ynh_add_systemd_config --service=$flohmarkt_filename
@ -104,6 +107,6 @@ ynh_add_fail2ban_config --logpath="$flohmarkt_logfile" --failregex='INFO: +<HOST
# start flohmarkt # start flohmarkt
ynh_script_progression --message="Starting flohmarkt..." --weight=3 ynh_script_progression --message="Starting flohmarkt..." --weight=3
ynh_systemd_action --service_name=$flohmarkt_filename --action="start" --line_match='INFO: *Application startup complete.' --log_path="$flohmarkt_logfile" --timeout=30 flohmarkt_ynh_start_service
ynh_script_progression --message="Upgrade of $app completed" --last ynh_script_progression --message="Upgrade of $app completed" --last