From b6d9fac30f7e572c31d775ab187f4b4d7173afae Mon Sep 17 00:00:00 2001 From: Chris Vogel Date: Mon, 6 May 2024 07:47:13 +0200 Subject: [PATCH] New file- and pathnames Quiet a ride, but on my test system it installs and removes. Upgrade will not work, yet. Renaming is missing. Multiple installs should work. --- conf/05-flohmarkt.ini | 1 - conf/flohmarkt.conf | 7 ++++- conf/systemd.service | 6 ++--- doc/DEVELOPMENT.md | 11 ++++---- manifest.toml | 9 +++---- scripts/_common.sh | 63 +++++++++++++++++++++++++++++++++++++++---- scripts/backup | 10 +++---- scripts/install | 36 +++++++++++++++---------- scripts/remove | 45 +++++++++++++++++-------------- scripts/restore | 16 +++++------ scripts/upgrade | 27 ++++++++++++------- 11 files changed, 155 insertions(+), 76 deletions(-) diff --git a/conf/05-flohmarkt.ini b/conf/05-flohmarkt.ini index 808d3c0..b6d6553 100644 --- a/conf/05-flohmarkt.ini +++ b/conf/05-flohmarkt.ini @@ -2,5 +2,4 @@ ; prevent non admin users to be able to access the list of all databases admin_only_all_dbs = true -; Defines the port number to listen: port = __PORT_COUCHDB__ diff --git a/conf/flohmarkt.conf b/conf/flohmarkt.conf index 61de2d0..f42af97 100644 --- a/conf/flohmarkt.conf +++ b/conf/flohmarkt.conf @@ -6,7 +6,12 @@ JwtSecret = __JWTSECRET__ DataPath = __DATA_DIR__ [Database] -Server = http://__APP__:__PASSWORD_COUCHDB_FLOHMARKT__@127.0.0.1:__PORT_COUCHDB__/ +UseHttps = 0 +Host = 127.0.0.1 +User = __APP__ +Password = __PASSWORD_COUCHDB_FLOHMARKT__ +Port = __PORT_COUCHDB__ +Database = __APP__ [SMTP] Server = 127.0.0.1 diff --git a/conf/systemd.service b/conf/systemd.service index 35cf147..79938cb 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -6,11 +6,11 @@ After=network.target couchdb.service Type=simple User=__APP__ Group=__APP__ -WorkingDirectory=__FLOHMARKT_INSTALL__ +WorkingDirectory=__FLOHMARKT_APP_DIR__ Environment="VENV_DIR=__FLOHMARKT_VENV_DIR__" -ExecStart=/bin/bash -c "__FLOHMARKT_VENV_DIR__/bin/uvicorn --host 127.0.0.1 --port 8000 --reload flohmarkt.web:start 2>&1 | /usr/bin/ts '%%Y-%%m-%%d %%H:%%M:%%S'" +ExecStart=/bin/bash -c "__FLOHMARKT_VENV_DIR__/bin/uvicorn --host 127.0.0.1 --port __PORT__ flohmarkt.web:start 2>&1 | /usr/bin/ts '%%Y-%%m-%%d %%H:%%M:%%S'" # nicer logfile naming https://codeberg.org/flohmarkt/flohmarkt_ynh/issues/38 -StandardOutput=append:/var/log/__ID__/__APP__.log +StandardOutput=append:__FLOHMARKT_LOGFILE__ StandardError=inherit # Sandboxing options to harden security diff --git a/doc/DEVELOPMENT.md b/doc/DEVELOPMENT.md index e3d1dc5..2a17e81 100644 --- a/doc/DEVELOPMENT.md +++ b/doc/DEVELOPMENT.md @@ -23,7 +23,7 @@ Your opinion is appreciated on this topic. The codeberg repository is meant to be bleeding edge and we'll try to follow the HEAD of [flohmarkts](https://codeberg.org/flohmarkt/flohmarkt) repository closely. -Once in a while we'll reach the point to tag a new `-ynhX` version for changes of the yunohost integration or we'll want to release a new version of flohmarkt or both. +Once in a while we'll reach the point to tag a new `~ynhX` version for changes of the yunohost integration or we'll want to release a new version of flohmarkt or both. To do so we'll push the according changes to the [flohmarkt repository at github](https://github.com/YunoHost-Apps/flohmarkt_ynh) to make upgrades available to the yunohost community. @@ -40,10 +40,11 @@ Because of https://github.com/YunoHost-Apps/flohmarkt_ynh/pull/2#issuecomment-20 ### pushing to github * make sure the local git and the codeberg git are in sync on their testing branch -* tag a new version on codeberg `.-ynh`, e.g. `0.01-ynh5`. `.` is the flohmarkt version. `ynhX` is the version of the integration into flohmarkt (this repo). - * new flohmarkt version: only `manifest.toml` changed to point to the newer source archive - → change `.-ynh` according to the new flohmarkt version - * changes in integration: scripts, conf files or `doc/*` changed +* tag a new version on codeberg `.~ynh`, e.g. `0.01~ynh5`. `.` is the flohmarkt version. `ynhX` is the version of the integration into flohmarkt (this repo). + * new flohmarkt version: `manifest.toml` changed to point to the newer source archive + → change `.~ynh` according to the new flohmarkt version + → reset `X` in `~ynh` to `0` + * **only** changes in integration, **no new flohmarkt version in manifest.toml** → increment `` to signal a new version of the yunohost integration * push the local testing branch to github, if this fails: * there might for some reason exist an old testing branch that had not been deleted after the PR to the github master branch - check carefully and delete the existing testing branch diff --git a/manifest.toml b/manifest.toml index 43b638e..a8a7072 100644 --- a/manifest.toml +++ b/manifest.toml @@ -108,8 +108,8 @@ ram.runtime = "100M" # This will pre-fetch the asset which can then be deployed during the install/upgrade scripts with : # ynh_setup_source --dest_dir="$install_dir" # You can also define other assets than "main" and add --source_id="foobar" in the previous command - url = "https://codeberg.org/flohmarkt/flohmarkt/archive/6b396428ee52acba99483487e34eb0b258e339eb.tar.gz" - sha256 = "2167a94e209764fd7fde06b77e6b2fe845ed493f0fdab1dc19053ecd7d89d60f" + url = "https://codeberg.org/flohmarkt/flohmarkt/archive/2c5ea313d9b04dad25649335f415af5ca484f262.tar.gz" + sha256 = "ce08228e2e9e650925c53094bf9c02bac8cdcb03a931f262034802ce6541e1f7" # These infos are used by https://github.com/YunoHost/apps/blob/master/tools/autoupdate_app_sources/autoupdate_app_sources.py # to auto-update the previous asset urls and sha256sum + manifest version @@ -134,9 +134,8 @@ ram.runtime = "100M" [resources.install_dir] dir = "/opt/flohmarkt" - [resources.data_dir] - # This will create/remove the data dir as /home/yunohost.app/$app - # and store the corresponding setting $data_dir + # [resources.data_dir] + # we'll take care of this inside the install script and save it to the settings [resources.permissions] # This will configure SSOwat permission for $domain/$path/ diff --git a/scripts/_common.sh b/scripts/_common.sh index 92bb029..3459cd3 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,17 +4,70 @@ # COMMON VARIABLES #================================================= -# replace '/' by nothing for the path -if [ "$path" == '/' ]; then url_path=''; else url_path=$path; fi +## new filenames starting 0.00~ynh5 +# make a filename/service name from domain/path +if [[ "$path" == /* ]]; then + url_path="${path:1}" +fi +if [[ "__${url_path}__" == '____' ]]; then + flohmarkt_filename="$domain" +else + flohmarkt_filename="$domain-${url_path}" +fi +# just in case we append $app to make it really unique +# this filename is used for logfile name and systemd.service name +flohmarkt_filename="${flohmarkt_filename//[^A-Za-z0-9._-]/_}_${app}" +# # directory flohmarkts software is installed to -flohmarkt_install="/opt/${id}/${domain}${url_path}/src" -# diretory the venv for flohmarkt is installed to -flohmarkt_venv_dir="/opt/${id}/${domain}${url_path}/venv" +# contains ./venv and ./src as sub-directories +flohmarkt_install="/opt/${id}/${domain}/${url_path}" +flohmarkt_venv_dir="${flohmarkt_install}/venv" +flohmarkt_app_dir="${flohmarkt_install}/app" +# directory containing logfiles +flohmarkt_log_dir="/var/log/${id}/${flohmarkt_filename}" +# filename for logfiles - ¡ojo! if not ends with .log will be interpreted +# as a directory by ynh_use_logrotate +# https://github.com/YunoHost/issues/issues/2383 +flohmarkt_logfile="${flohmarkt_log_dir}/${app}.log" +# flohmarkt data_dir follows the naming convention above +# its saved to settings during install +flohmarkt_data_dir="/home/yunohost.app/${flohmarkt_filename}" + +## old filenames before 0.00~ynh5 - for reference and needed to +# migrate (see below) +flohmarkt_old_install="$install_dir/$app/" +flohmarkt_old_venv_dir="$install_dir/venv" +flohmarkt_old_log_dir="/var/log/$app/" +flohmarkt_old_logfile="$app" +flohmarkt_old_service="$app" #================================================= # PERSONAL HELPERS #================================================= +# move files and directories to their new places +flohmarkt_ynh_upgrade_path_ynh5() { + # flohmarkt and couchdb are already stopped in upgrade script + # move install_dir + # move venv_dir + # move data_dir + # move systemd.service + # move logfiles + # update settings for above + + false + # there's still some work open - see above +} + +# to follow the naming convention including information about domain +# and path we do create the data_dir here and save it during install +# to the settings of this flohmarkt instance +flohmarkt_ynh_create_data_dir() { + mkdir -p $data_dir + chown $app: $data_dir + chmod 750 $data_dir +} + #================================================= # EXPERIMENTAL HELPERS #================================================= diff --git a/scripts/backup b/scripts/backup index afe4b97..f00fac9 100755 --- a/scripts/backup +++ b/scripts/backup @@ -4,19 +4,19 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers ynh_print_info --message="Declaring files to be backed up..." -ynh_backup --src_path="$install_dir" +ynh_backup --src_path="$flohmarkt_install" ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf" 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/$app.service" -ynh_backup --src_path="/var/log/$app" +ynh_backup --src_path="/etc/systemd/system/$flohmarkt_filename.service" +ynh_backup --src_path="${flohmarkt_logfile}*" # for the following backups we'll want to stop flohmarkt and couchdb # to guarentee a consistant state ynh_print_info --message="Stopping flohmarkt and couchdb to backup data..." -yunohost service stop flohmarkt +yunohost service stop $flohmarkt_filename systemctl stop couchdb # https://codeberg.org/ChriChri/flohmarkt_ynh/issues/24 @@ -29,7 +29,7 @@ systemctl stop couchdb # if this becomes a pain we'll need to stop deleting this directories on 'remove' # ynh_backup --src_path="$data_dir" --is_big # ynh_backup --src_path="/var/lib/couchdb" --is_big -ynh_backup --src_path="$data_dir" +ynh_backup --src_path="$flohmarkt_data_dir" ynh_backup --src_path="/var/lib/couchdb" ynh_print_info --message="...done. Starting couchdb and flohmarkt." diff --git a/scripts/install b/scripts/install index 1f84a76..f7da705 100755 --- a/scripts/install +++ b/scripts/install @@ -16,6 +16,12 @@ then exit 1 fi +# create and setup $data_dir +data_dir="${flohmarkt_data_dir}" +ynh_script_progression --message="Creating data_dir '$data_dir'..." --weight=2 +ynh_app_setting_set --app=$app --key=data_dir --value="$data_dir" +flohmarkt_ynh_create_data_dir + # INITIALIZE AND STORE SETTINGS # todo: do we need to store the password un-encrypted somewhere on the system? # → there's no way to get the admin password later if sometimes in the future deleting @@ -62,7 +68,7 @@ systemctl restart couchdb systemctl status couchdb # get flohmarkt -ynh_setup_source --dest_dir="$flohmarkt_install" +ynh_setup_source --dest_dir="$flohmarkt_app_dir" # setup python environment for flohmarkt ynh_secure_remove "$flohmarkt_venv_dir" @@ -75,7 +81,7 @@ python3 -m venv --without-pip "$flohmarkt_venv_dir" set -o nounset set -x $flohmarkt_venv_dir/bin/python3 -m ensurepip - $flohmarkt_venv_dir/bin/pip3 install -r "$flohmarkt_install/requirements.txt" + $flohmarkt_venv_dir/bin/pip3 install -r "$flohmarkt_app_dir/requirements.txt" ) # JwtSecret @@ -87,24 +93,24 @@ password_couchdb_flohmarkt=$(ynh_string_random --length=31 --filter='A-Za-z0-9_. ynh_app_setting_set --app=$app --key=password_couchdb_flohmarkt --value="$password_couchdb_flohmarkt" # generate flohmarkt.conf -ynh_add_config --template="../conf/flohmarkt.conf" --destination="$flohmarkt_install/flohmarkt.conf" +ynh_add_config --template="../conf/flohmarkt.conf" --destination="$flohmarkt_app_dir/flohmarkt.conf" # setup couchdb ( set +o nounset source "$flohmarkt_venv_dir/bin/activate" set -o nounset - cd "$flohmarkt_install" + cd "$flohmarkt_app_dir" # initialize_couchdb seems to re-try on connect problems endlessly blocking the yunohost api # give it 45 seconds to finish and then fail # https://codeberg.org/ChriChri/flohmarkt_ynh/issues/13 - timeout 45 python3 initialize_couchdb.py $password_couchdb_admin $password_couchdb_flohmarkt + timeout 45 python3 initialize_couchdb.py $password_couchdb_admin ) # SETUP LOGROTATE ynh_script_progression --message="Configuring log rotation..." --weight=2 # Use logrotate to manage application logfile(s) -ynh_use_logrotate +ynh_use_logrotate --logfile=$flohmarkt_logfile # NGINX CONFIGURATION ynh_script_progression --message="Configuring NGINX web server..." --weight=3 @@ -114,19 +120,21 @@ ynh_add_nginx_config # systemd.service ynh_script_progression --message="Configuring a systemd service..." --weight=1 # Create a dedicated systemd config -ynh_add_systemd_config +ynh_add_systemd_config --service=$flohmarkt_filename # integrate into yunohost ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 -yunohost service add $app --description="A decentral federated small advertisement platform" --log="/var/log/$app/$app.log" +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 "/var/log/$app" -touch "/var/log/$app/$app.log" -chmod 640 "/var/log/$app/$app.log" +mkdir -m755 -p "$flohmarkt_log_dir" +touch "$flohmarkt_logfile" +chmod 640 "$flohmarkt_logfile" # start service -ynh_systemd_action --service_name=$app --action="start" +ynh_systemd_action --service_name=$flohmarkt_filename --action="start" +# https://codeberg.org/flohmarkt/flohmarkt_ynh/issues/44 +# --line_match="INFO: Application startup complete." # SETUP FAIL2BAN ynh_script_progression --message="Configuring Fail2Ban..." --weight=3 -ynh_add_fail2ban_config --logpath="/var/log/$app/$app.log" --failregex='INFO: +:\d+ - "POST /token HTTP/\d+\.\d+" 403 Forbidden' --max_retry=5 +ynh_add_fail2ban_config --logpath="$flohmarkt_logfile" --failregex='INFO: +:\d+ - "POST /token HTTP/\d+\.\d+" 403 Forbidden' --max_retry=5 -ynh_script_progression --message="Installation of $app completed" --last +ynh_script_progression --message="Installation of $id completed" --last diff --git a/scripts/remove b/scripts/remove index 9d71d4f..3b54eb9 100755 --- a/scripts/remove +++ b/scripts/remove @@ -18,36 +18,40 @@ ynh_script_progression --message="Removing system configurations related to $app # Stop flohmarkt service ynh_script_progression --message="Stopping $app..." --weight=2 -yunohost service stop $app +yunohost service stop $flohmarkt_filename # Remove the service from the list of services known by YunoHost (added from `yunohost service add`) -if ynh_exec_warn_less yunohost service status $app >/dev/null +if ynh_exec_warn_less yunohost service status $flohmarkt_filename >/dev/null then ynh_script_progression --message="Removing $app service integration..." --weight=2 - yunohost service remove $app + yunohost service remove $flohmarkt_filename fi -ynh_script_progression --message="Stopping couchdb..." --weight=2 -systemctl stop couchdb - -ynh_script_progression --message="Removing databases..." --weight=2 -# remove flohmarkt database and database user -# ynh_script_progression --message="removing flohmarkt couchdb user and database" --weight=2 -# @@ wie komme ich hier an das admin-password, falls ich es brauche? -# * brauche ich es? → ja -# db: -# curl -X DELETE 'http://127.0.0.1:5984/flohmarkt' --user ':' -# user: -# curl -X DELETE "http://127.0.0.1:5984/_users/org.couchdb.user%3Aflohmarkt?rev=`curl -sX GET 'http://127.0.0.1:5984/_users/org.couchdb.user%3Aflohmarkt' --user 'admin:bla42fasel' | jq -r ._rev`" --user ':' -# @@ todo improve this like above -# https://codeberg.org/ChriChri/flohmarkt_ynh/issues/12 -ynh_secure_remove --file=/var/lib/couchdb +## This needs to be rewritten: Only delete the database of the instance being removed +# https://codeberg.org/flohmarkt/flohmarkt_ynh/issues/12 +# ynh_script_progression --message="Stopping couchdb..." --weight=2 +# systemctl stop couchdb +# +# ynh_script_progression --message="Removing databases..." --weight=2 +# # remove flohmarkt database and database user +# # ynh_script_progression --message="removing flohmarkt couchdb user and database" --weight=2 +# # @@ wie komme ich hier an das admin-password, falls ich es brauche? +# # * brauche ich es? → ja +# # db: +# # curl -X DELETE 'http://127.0.0.1:5984/flohmarkt' --user ':' +# # user: +# # curl -X DELETE "http://127.0.0.1:5984/_users/org.couchdb.user%3Aflohmarkt?rev=`curl -sX GET 'http://127.0.0.1:5984/_users/org.couchdb.user%3Aflohmarkt' --user 'admin:bla42fasel' | jq -r ._rev`" --user ':' +# # @@ todo improve this like above +# # https://codeberg.org/ChriChri/flohmarkt_ynh/issues/12 +# ynh_secure_remove --file=/var/lib/couchdb # Remove the app-specific logrotate config ynh_remove_logrotate -# remove log directory -ynh_secure_remove --file="/var/log/$app/$app.log" +# remove logfiles directory +# https://codeberg.org/flohmarkt/flohmarkt_ynh/issues/29 +# can only remove a subdir or one file +ynh_secure_remove --file="${flohmarkt_log_dir}" # Remove the dedicated NGINX config ynh_remove_nginx_config @@ -56,6 +60,7 @@ ynh_remove_nginx_config ynh_remove_fail2ban_config # Remove home +# https://codeberg.org/flohmarkt/flohmarkt_ynh/issues/29 ynh_script_progression --message="Removing data directory..." --weight=2 ynh_secure_remove --file=$data_dir diff --git a/scripts/restore b/scripts/restore index c3de18a..e381609 100755 --- a/scripts/restore +++ b/scripts/restore @@ -56,16 +56,16 @@ mkdir -p $data_dir # If the logfile(or maybe just -directory?) is missing the service will not start # on a fresh install, because directory and/or file do not exist. ynh_script_progression --message="Restoring log directory and logfiles..." --weight=1 -ynh_restore_file --origin_path="/var/log/$app" --not_mandatory -mkdir -p -m755 "/var/log/$app" -touch "/var/log/$app/$app.log" +ynh_restore_file --origin_path="$flohmarkt_log_dir" --not_mandatory +mkdir -p -m755 "$flohmarkt_log_dir" +touch "$flohmarkt_logfile" # logfile contains possibly the secret setup URL -chmod 640 "/var/log/$app/$app.log" +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/$app.conf" -ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf" +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_systemd_action --action=restart --service_name=fail2ban # RESTORE THE NGINX CONFIGURATION @@ -78,9 +78,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/$app.service" +ynh_restore_file --origin_path="/etc/systemd/system/$flohmarkt_filename.service" ynh_systemd_action --action=enable -yunohost service add $app --description="A decentral federated small advertisement platform" --log="/var/log/$app/$app.log" +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." # RELOAD NGINX diff --git a/scripts/upgrade b/scripts/upgrade index 8b2e17b..1550954 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -15,6 +15,15 @@ ynh_systemd_action --service_name=$app --action="stop" # stop couchdb ynh_systemd_action --service_name=couchdb --action="stop" +# Upgrade ynh4 → ynh5, change of paths and filenames +# https://matrix.to/#/!PauySEslPVuJCJCwlZ:matrix.org/$auU_rSL6MACt9wkyFGlCQbO8ivFlU0ztYW74TimZdcM?via=matrix.org&via=aria-net.org&via=sans-nuage.fr +# and follow-ups +if ynh_compare_current_package_version --comparision lt --version 0.00~ynh5 && + ( [[ $upgrade_type == UPGRADE_PACKAGE ]] || [[ $upgrade_type == UPGRADE_APP ]] ) +then + flohmarkt_ynh_upgrade_path_ynh5 +fi + # upgrade couchdb ynh_script_progression --message="Upgrading CouchDB..." --weight=50 echo "\ @@ -46,9 +55,9 @@ systemctl status couchdb # install upgrade for flohmarkt ynh_script_progression --message="Upgrading flohmarkt..." --weight=4 -ynh_setup_source --dest_dir="$flohmarkt_install/" +ynh_setup_source --dest_dir="$flohmarkt_app_dir/" -ynh_script_progression --message="Upgrading flohmarkt python dependencies..." --weight=5 +ynh_script_progression --message="Upgrading flohmarkt python dependencies..." --weight=6 # upgrade python environment / install new dependencies ( set +o nounset @@ -56,12 +65,12 @@ ynh_script_progression --message="Upgrading flohmarkt python dependencies..." -- set -o nounset set -x $flohmarkt_venv_dir/bin/python3 -m ensurepip - $flohmarkt_venv_dir/bin/pip3 install -r "$flohmarkt_install/requirements.txt" + $flohmarkt_venv_dir/bin/pip3 install -r "$flohmarkt_app_dir/requirements.txt" ) # upgrade flohmarkt.conf ynh_script_progression --message="Upgrading flohmarkt configuration..." --weight=1 -ynh_add_config --template="../conf/flohmarkt.conf" --destination="$flohmarkt_install/flohmarkt.conf" +ynh_add_config --template="../conf/flohmarkt.conf" --destination="$flohmarkt_app_dir/flohmarkt.conf" ynh_script_progression --message="Upgrading flohmarkt couchdb..." --weight=10 # run initialize_couchdb.py @@ -69,7 +78,7 @@ ynh_script_progression --message="Upgrading flohmarkt couchdb..." --weight=10 set +o nounset source "$flohmarkt_venv_dir/bin/activate" set -o nounset - cd "$flohmarkt_install" + cd "$flohmarkt_app_dir" # initialize_couchdb seems to re-try on connect problems endlessly blocking the yunohost api # give it 45 seconds to finish and then fail # https://codeberg.org/ChriChri/flohmarkt_ynh/issues/13 @@ -78,10 +87,10 @@ ynh_script_progression --message="Upgrading flohmarkt couchdb..." --weight=10 # systemd service upgrade ynh_script_progression --message="Upgrading flohmarkt systemd service..." --weight=1 -ynh_add_systemd_config +ynh_add_systemd_config --service=$flohmarkt_filename # INTEGRATE SERVICE IN YUNOHOST ynh_script_progression --message="Integrating service in YunoHost..." --weight=2 -yunohost service add $app --description="A decentral federated small advertisement platform" --log="/var/log/$app/$app.log" +yunohost service add $flohmarkt_filename --description="A decentral federated small advertisement platform" --log="$flohmarkt_logfile" # upgrade logrotate ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1 @@ -94,10 +103,10 @@ ynh_add_nginx_config # UPGRADE FAIL2BAN ynh_script_progression --message="Reconfiguring Fail2Ban..." --weight=3 -ynh_add_fail2ban_config --logpath="/var/log/$app/$app.log" --failregex='INFO: +:\d+ - "POST /token HTTP/\d+\.\d+" 403 Forbidden' --max_retry=5 +ynh_add_fail2ban_config --logpath="$flohmarkt_logfile" --failregex='INFO: +:\d+ - "POST /token HTTP/\d+\.\d+" 403 Forbidden' --max_retry=5 # start flohmarkt ynh_script_progression --message="Starting flohmarkt..." --weight=3 -ynh_systemd_action --service_name=$app --action="start" --line_match="INFO: Application startup complete." +ynh_systemd_action --service_name=$flohmarkt_filename --action="start" --line_match="INFO: Application startup complete." ynh_script_progression --message="Upgrade of $app completed" --last