Sfoglia il codice sorgente

corrections to backup/restore

Chris Vogel 1 anno fa
parent
commit
94ec94e32d
7 ha cambiato i file con 56 aggiunte e 20 eliminazioni
  1. 13 0
      doc/POST_INSTALL.md
  2. 6 6
      doc/PRE_INSTALL.md
  3. 17 0
      scripts/_common.sh
  4. 2 2
      scripts/backup
  5. 6 4
      scripts/install
  6. 7 6
      scripts/restore
  7. 5 2
      scripts/upgrade

+ 13 - 0
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)

+ 6 - 6
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.
 

+ 17 - 0
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"

+ 2 - 2
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)."

+ 6 - 4
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: +<HOST
 ln -s "$flohmarkt_install" "$flohmarkt_sym_install"
 ln -s "$flohmarkt_data_dir" "$flohmarkt_sym_data_dir"
 
-# debug
-env
+# start service
+flohmarkt_ynh_start_service
 
 ynh_script_progression --message="Installation of $id completed" --last

+ 7 - 6
scripts/restore

@@ -5,6 +5,7 @@ source /usr/share/yunohost/helpers
 
 # restore couchdb directory
 ynh_script_progression --message="Restoring couchdb directory..." --weight=1
+# argh, need this for a single database
 ynh_restore_file --origin_path="/var/lib/couchdb"
 
 # reinstall couchdb
@@ -42,11 +43,11 @@ systemctl status couchdb
 
 # RESTORE THE APP MAIN DIR
 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
 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
 
 # restore logfiles
@@ -64,8 +65,8 @@ chmod 640 "$flohmarkt_logfile"
 
 # RESTORE FAIL2BAN CONFIGURATION
 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/filter.d/$flohmarkt_logfile.conf"
+ynh_restore_file --origin_path="/etc/fail2ban/jail.d/$app.conf"
+ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf"
 ynh_systemd_action --action=restart --service_name=fail2ban
 
 # 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
 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_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"
-ynh_systemd_action --action=start --line_match="INFO:     Application startup complete."
+flohmarkt_ynh_start_service
 
 # RELOAD NGINX
 ynh_script_progression --message="Reloading NGINX web server..." --weight=1

+ 5 - 2
scripts/upgrade

@@ -15,7 +15,7 @@ upgrade_type=$(ynh_check_app_version_changed)
 
 ynh_script_progression --message="Stopping flohmarkt and CouchDB..." --weight=5
 # stop flohmarkt
-ynh_systemd_action --service_name=$app --action="stop"
+flohmarkt_ynh_stop_service
 # stop couchdb
 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
 )
 
+# set file permissions for install dir
+flohmarkt_ynh_set_permission
+
 # systemd service upgrade
 ynh_script_progression --message="Upgrading flohmarkt systemd service..." --weight=1
 ynh_add_systemd_config --service=$flohmarkt_filename
@@ -104,6 +107,6 @@ ynh_add_fail2ban_config --logpath="$flohmarkt_logfile" --failregex='INFO: +<HOST
 
 # start flohmarkt
 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