mirror of
https://github.com/YunoHost-Apps/flohmarkt_ynh.git
synced 2024-09-03 18:36:30 +02:00
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.
This commit is contained in:
parent
e73534d4cd
commit
b6d9fac30f
11 changed files with 155 additions and 76 deletions
|
@ -2,5 +2,4 @@
|
||||||
; prevent non admin users to be able to access the list of all databases
|
; prevent non admin users to be able to access the list of all databases
|
||||||
admin_only_all_dbs = true
|
admin_only_all_dbs = true
|
||||||
|
|
||||||
; Defines the port number to listen:
|
|
||||||
port = __PORT_COUCHDB__
|
port = __PORT_COUCHDB__
|
||||||
|
|
|
@ -6,7 +6,12 @@ JwtSecret = __JWTSECRET__
|
||||||
DataPath = __DATA_DIR__
|
DataPath = __DATA_DIR__
|
||||||
|
|
||||||
[Database]
|
[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]
|
[SMTP]
|
||||||
Server = 127.0.0.1
|
Server = 127.0.0.1
|
||||||
|
|
|
@ -6,11 +6,11 @@ After=network.target couchdb.service
|
||||||
Type=simple
|
Type=simple
|
||||||
User=__APP__
|
User=__APP__
|
||||||
Group=__APP__
|
Group=__APP__
|
||||||
WorkingDirectory=__FLOHMARKT_INSTALL__
|
WorkingDirectory=__FLOHMARKT_APP_DIR__
|
||||||
Environment="VENV_DIR=__FLOHMARKT_VENV_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
|
# nicer logfile naming https://codeberg.org/flohmarkt/flohmarkt_ynh/issues/38
|
||||||
StandardOutput=append:/var/log/__ID__/__APP__.log
|
StandardOutput=append:__FLOHMARKT_LOGFILE__
|
||||||
StandardError=inherit
|
StandardError=inherit
|
||||||
|
|
||||||
# Sandboxing options to harden security
|
# Sandboxing options to harden security
|
||||||
|
|
|
@ -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.
|
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.
|
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
|
### pushing to github
|
||||||
|
|
||||||
* make sure the local git and the codeberg git are in sync on their testing branch
|
* make sure the local git and the codeberg git are in sync on their testing branch
|
||||||
* tag a new version on codeberg `<major>.<minor>-ynh<X>`, e.g. `0.01-ynh5`. `<major>.<minor>` is the flohmarkt version. `ynhX` is the version of the integration into flohmarkt (this repo).
|
* tag a new version on codeberg `<major>.<minor>~ynh<X>`, e.g. `0.01~ynh5`. `<major>.<minor>` 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
|
* new flohmarkt version: `manifest.toml` changed to point to the newer source archive
|
||||||
→ change `<major>.<minor>-ynh<X>` according to the new flohmarkt version
|
→ change `<major>.<minor>~ynh<X>` according to the new flohmarkt version
|
||||||
* changes in integration: scripts, conf files or `doc/*` changed
|
→ reset `X` in `~ynh<X>` to `0`
|
||||||
|
* **only** changes in integration, **no new flohmarkt version in manifest.toml**
|
||||||
→ increment `<X>` to signal a new version of the yunohost integration
|
→ increment `<X>` to signal a new version of the yunohost integration
|
||||||
* push the local testing branch to github, if this fails:
|
* 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
|
* 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
|
||||||
|
|
|
@ -108,8 +108,8 @@ ram.runtime = "100M"
|
||||||
# This will pre-fetch the asset which can then be deployed during the install/upgrade scripts with :
|
# This will pre-fetch the asset which can then be deployed during the install/upgrade scripts with :
|
||||||
# ynh_setup_source --dest_dir="$install_dir"
|
# ynh_setup_source --dest_dir="$install_dir"
|
||||||
# You can also define other assets than "main" and add --source_id="foobar" in the previous command
|
# 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"
|
url = "https://codeberg.org/flohmarkt/flohmarkt/archive/2c5ea313d9b04dad25649335f415af5ca484f262.tar.gz"
|
||||||
sha256 = "2167a94e209764fd7fde06b77e6b2fe845ed493f0fdab1dc19053ecd7d89d60f"
|
sha256 = "ce08228e2e9e650925c53094bf9c02bac8cdcb03a931f262034802ce6541e1f7"
|
||||||
|
|
||||||
# These infos are used by https://github.com/YunoHost/apps/blob/master/tools/autoupdate_app_sources/autoupdate_app_sources.py
|
# 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
|
# to auto-update the previous asset urls and sha256sum + manifest version
|
||||||
|
@ -134,9 +134,8 @@ ram.runtime = "100M"
|
||||||
[resources.install_dir]
|
[resources.install_dir]
|
||||||
dir = "/opt/flohmarkt"
|
dir = "/opt/flohmarkt"
|
||||||
|
|
||||||
[resources.data_dir]
|
# [resources.data_dir]
|
||||||
# This will create/remove the data dir as /home/yunohost.app/$app
|
# we'll take care of this inside the install script and save it to the settings
|
||||||
# and store the corresponding setting $data_dir
|
|
||||||
|
|
||||||
[resources.permissions]
|
[resources.permissions]
|
||||||
# This will configure SSOwat permission for $domain/$path/
|
# This will configure SSOwat permission for $domain/$path/
|
||||||
|
|
|
@ -4,17 +4,70 @@
|
||||||
# COMMON VARIABLES
|
# COMMON VARIABLES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# replace '/' by nothing for the path
|
## new filenames starting 0.00~ynh5
|
||||||
if [ "$path" == '/' ]; then url_path=''; else url_path=$path; fi
|
# 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
|
# directory flohmarkts software is installed to
|
||||||
flohmarkt_install="/opt/${id}/${domain}${url_path}/src"
|
# contains ./venv and ./src as sub-directories
|
||||||
# diretory the venv for flohmarkt is installed to
|
flohmarkt_install="/opt/${id}/${domain}/${url_path}"
|
||||||
flohmarkt_venv_dir="/opt/${id}/${domain}${url_path}/venv"
|
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
|
# 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
|
# EXPERIMENTAL HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -4,19 +4,19 @@ source ../settings/scripts/_common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
ynh_print_info --message="Declaring files to be backed up..."
|
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/nginx/conf.d/$domain.d/$app.conf"
|
||||||
ynh_backup --src_path="/etc/fail2ban/jail.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/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/$app.service"
|
ynh_backup --src_path="/etc/systemd/system/$flohmarkt_filename.service"
|
||||||
ynh_backup --src_path="/var/log/$app"
|
ynh_backup --src_path="${flohmarkt_logfile}*"
|
||||||
|
|
||||||
# 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
|
||||||
ynh_print_info --message="Stopping flohmarkt and couchdb to backup data..."
|
ynh_print_info --message="Stopping flohmarkt and couchdb to backup data..."
|
||||||
yunohost service stop flohmarkt
|
yunohost service stop $flohmarkt_filename
|
||||||
systemctl stop couchdb
|
systemctl stop couchdb
|
||||||
|
|
||||||
# https://codeberg.org/ChriChri/flohmarkt_ynh/issues/24
|
# 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'
|
# 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="$data_dir" --is_big
|
||||||
# ynh_backup --src_path="/var/lib/couchdb" --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_backup --src_path="/var/lib/couchdb"
|
||||||
|
|
||||||
ynh_print_info --message="...done. Starting couchdb and flohmarkt."
|
ynh_print_info --message="...done. Starting couchdb and flohmarkt."
|
||||||
|
|
|
@ -16,6 +16,12 @@ then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
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
|
# INITIALIZE AND STORE SETTINGS
|
||||||
# todo: do we need to store the password un-encrypted somewhere on the system?
|
# 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
|
# → 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
|
systemctl status couchdb
|
||||||
|
|
||||||
# get flohmarkt
|
# get flohmarkt
|
||||||
ynh_setup_source --dest_dir="$flohmarkt_install"
|
ynh_setup_source --dest_dir="$flohmarkt_app_dir"
|
||||||
|
|
||||||
# setup python environment for flohmarkt
|
# setup python environment for flohmarkt
|
||||||
ynh_secure_remove "$flohmarkt_venv_dir"
|
ynh_secure_remove "$flohmarkt_venv_dir"
|
||||||
|
@ -75,7 +81,7 @@ python3 -m venv --without-pip "$flohmarkt_venv_dir"
|
||||||
set -o nounset
|
set -o nounset
|
||||||
set -x
|
set -x
|
||||||
$flohmarkt_venv_dir/bin/python3 -m ensurepip
|
$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
|
# 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"
|
ynh_app_setting_set --app=$app --key=password_couchdb_flohmarkt --value="$password_couchdb_flohmarkt"
|
||||||
|
|
||||||
# generate flohmarkt.conf
|
# 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
|
# setup couchdb
|
||||||
(
|
(
|
||||||
set +o nounset
|
set +o nounset
|
||||||
source "$flohmarkt_venv_dir/bin/activate"
|
source "$flohmarkt_venv_dir/bin/activate"
|
||||||
set -o nounset
|
set -o nounset
|
||||||
cd "$flohmarkt_install"
|
cd "$flohmarkt_app_dir"
|
||||||
# initialize_couchdb seems to re-try on connect problems endlessly blocking the yunohost api
|
# initialize_couchdb seems to re-try on connect problems endlessly blocking the yunohost api
|
||||||
# give it 45 seconds to finish and then fail
|
# give it 45 seconds to finish and then fail
|
||||||
# https://codeberg.org/ChriChri/flohmarkt_ynh/issues/13
|
# 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
|
# SETUP LOGROTATE
|
||||||
ynh_script_progression --message="Configuring log rotation..." --weight=2
|
ynh_script_progression --message="Configuring log rotation..." --weight=2
|
||||||
# Use logrotate to manage application logfile(s)
|
# Use logrotate to manage application logfile(s)
|
||||||
ynh_use_logrotate
|
ynh_use_logrotate --logfile=$flohmarkt_logfile
|
||||||
|
|
||||||
# NGINX CONFIGURATION
|
# NGINX CONFIGURATION
|
||||||
ynh_script_progression --message="Configuring NGINX web server..." --weight=3
|
ynh_script_progression --message="Configuring NGINX web server..." --weight=3
|
||||||
|
@ -114,19 +120,21 @@ ynh_add_nginx_config
|
||||||
# systemd.service
|
# systemd.service
|
||||||
ynh_script_progression --message="Configuring a systemd service..." --weight=1
|
ynh_script_progression --message="Configuring a systemd service..." --weight=1
|
||||||
# Create a dedicated systemd config
|
# Create a dedicated systemd config
|
||||||
ynh_add_systemd_config
|
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 $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
|
# logfile contains possibly the secret setup URL
|
||||||
mkdir -m755 -p "/var/log/$app"
|
mkdir -m755 -p "$flohmarkt_log_dir"
|
||||||
touch "/var/log/$app/$app.log"
|
touch "$flohmarkt_logfile"
|
||||||
chmod 640 "/var/log/$app/$app.log"
|
chmod 640 "$flohmarkt_logfile"
|
||||||
# start service
|
# 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
|
# SETUP FAIL2BAN
|
||||||
ynh_script_progression --message="Configuring Fail2Ban..." --weight=3
|
ynh_script_progression --message="Configuring Fail2Ban..." --weight=3
|
||||||
ynh_add_fail2ban_config --logpath="/var/log/$app/$app.log" --failregex='INFO: +<HOST>:\d+ - "POST /token HTTP/\d+\.\d+" 403 Forbidden' --max_retry=5
|
ynh_add_fail2ban_config --logpath="$flohmarkt_logfile" --failregex='INFO: +<HOST>:\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
|
||||||
|
|
|
@ -18,36 +18,40 @@ ynh_script_progression --message="Removing system configurations related to $app
|
||||||
|
|
||||||
# Stop flohmarkt service
|
# Stop flohmarkt service
|
||||||
ynh_script_progression --message="Stopping $app..." --weight=2
|
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`)
|
# 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
|
then
|
||||||
ynh_script_progression --message="Removing $app service integration..." --weight=2
|
ynh_script_progression --message="Removing $app service integration..." --weight=2
|
||||||
yunohost service remove $app
|
yunohost service remove $flohmarkt_filename
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ynh_script_progression --message="Stopping couchdb..." --weight=2
|
## This needs to be rewritten: Only delete the database of the instance being removed
|
||||||
systemctl stop couchdb
|
# https://codeberg.org/flohmarkt/flohmarkt_ynh/issues/12
|
||||||
|
# ynh_script_progression --message="Stopping couchdb..." --weight=2
|
||||||
ynh_script_progression --message="Removing databases..." --weight=2
|
# systemctl stop couchdb
|
||||||
# remove flohmarkt database and database user
|
#
|
||||||
# ynh_script_progression --message="removing flohmarkt couchdb user and database" --weight=2
|
# ynh_script_progression --message="Removing databases..." --weight=2
|
||||||
# @@ wie komme ich hier an das admin-password, falls ich es brauche?
|
# # remove flohmarkt database and database user
|
||||||
# * brauche ich es? → ja
|
# # ynh_script_progression --message="removing flohmarkt couchdb user and database" --weight=2
|
||||||
# db:
|
# # @@ wie komme ich hier an das admin-password, falls ich es brauche?
|
||||||
# curl -X DELETE 'http://127.0.0.1:5984/flohmarkt' --user '<admin-user>:<admin-password>'
|
# # * brauche ich es? → ja
|
||||||
# user:
|
# # db:
|
||||||
# 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 '<admin-user>:<admin-password>'
|
# # curl -X DELETE 'http://127.0.0.1:5984/flohmarkt' --user '<admin-user>:<admin-password>'
|
||||||
# @@ todo improve this like above
|
# # user:
|
||||||
# https://codeberg.org/ChriChri/flohmarkt_ynh/issues/12
|
# # 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 '<admin-user>:<admin-password>'
|
||||||
ynh_secure_remove --file=/var/lib/couchdb
|
# # @@ 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
|
# Remove the app-specific logrotate config
|
||||||
ynh_remove_logrotate
|
ynh_remove_logrotate
|
||||||
|
|
||||||
# remove log directory
|
# remove logfiles directory
|
||||||
ynh_secure_remove --file="/var/log/$app/$app.log"
|
# 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
|
# Remove the dedicated NGINX config
|
||||||
ynh_remove_nginx_config
|
ynh_remove_nginx_config
|
||||||
|
@ -56,6 +60,7 @@ ynh_remove_nginx_config
|
||||||
ynh_remove_fail2ban_config
|
ynh_remove_fail2ban_config
|
||||||
|
|
||||||
# Remove home
|
# Remove home
|
||||||
|
# https://codeberg.org/flohmarkt/flohmarkt_ynh/issues/29
|
||||||
ynh_script_progression --message="Removing data directory..." --weight=2
|
ynh_script_progression --message="Removing data directory..." --weight=2
|
||||||
ynh_secure_remove --file=$data_dir
|
ynh_secure_remove --file=$data_dir
|
||||||
|
|
||||||
|
|
|
@ -56,16 +56,16 @@ mkdir -p $data_dir
|
||||||
# If the logfile(or maybe just -directory?) is missing the service will not start
|
# 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.
|
# on a fresh install, because directory and/or file do not exist.
|
||||||
ynh_script_progression --message="Restoring log directory and logfiles..." --weight=1
|
ynh_script_progression --message="Restoring log directory and logfiles..." --weight=1
|
||||||
ynh_restore_file --origin_path="/var/log/$app" --not_mandatory
|
ynh_restore_file --origin_path="$flohmarkt_log_dir" --not_mandatory
|
||||||
mkdir -p -m755 "/var/log/$app"
|
mkdir -p -m755 "$flohmarkt_log_dir"
|
||||||
touch "/var/log/$app/$app.log"
|
touch "$flohmarkt_logfile"
|
||||||
# logfile contains possibly the secret setup URL
|
# logfile contains possibly the secret setup URL
|
||||||
chmod 640 "/var/log/$app/$app.log"
|
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/$app.conf"
|
ynh_restore_file --origin_path="/etc/fail2ban/jail.d/$flohmarkt_logfile.conf"
|
||||||
ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf"
|
ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$flohmarkt_logfile.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
|
||||||
|
@ -78,9 +78,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/$app.service"
|
ynh_restore_file --origin_path="/etc/systemd/system/$flohmarkt_filename.service"
|
||||||
ynh_systemd_action --action=enable
|
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."
|
ynh_systemd_action --action=start --line_match="INFO: Application startup complete."
|
||||||
|
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
|
|
|
@ -15,6 +15,15 @@ ynh_systemd_action --service_name=$app --action="stop"
|
||||||
# stop couchdb
|
# stop couchdb
|
||||||
ynh_systemd_action --service_name=couchdb --action="stop"
|
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
|
# upgrade couchdb
|
||||||
ynh_script_progression --message="Upgrading CouchDB..." --weight=50
|
ynh_script_progression --message="Upgrading CouchDB..." --weight=50
|
||||||
echo "\
|
echo "\
|
||||||
|
@ -46,9 +55,9 @@ systemctl status couchdb
|
||||||
|
|
||||||
# install upgrade for flohmarkt
|
# install upgrade for flohmarkt
|
||||||
ynh_script_progression --message="Upgrading flohmarkt..." --weight=4
|
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
|
# upgrade python environment / install new dependencies
|
||||||
(
|
(
|
||||||
set +o nounset
|
set +o nounset
|
||||||
|
@ -56,12 +65,12 @@ ynh_script_progression --message="Upgrading flohmarkt python dependencies..." --
|
||||||
set -o nounset
|
set -o nounset
|
||||||
set -x
|
set -x
|
||||||
$flohmarkt_venv_dir/bin/python3 -m ensurepip
|
$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
|
# upgrade flohmarkt.conf
|
||||||
ynh_script_progression --message="Upgrading flohmarkt configuration..." --weight=1
|
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
|
ynh_script_progression --message="Upgrading flohmarkt couchdb..." --weight=10
|
||||||
# run initialize_couchdb.py
|
# run initialize_couchdb.py
|
||||||
|
@ -69,7 +78,7 @@ ynh_script_progression --message="Upgrading flohmarkt couchdb..." --weight=10
|
||||||
set +o nounset
|
set +o nounset
|
||||||
source "$flohmarkt_venv_dir/bin/activate"
|
source "$flohmarkt_venv_dir/bin/activate"
|
||||||
set -o nounset
|
set -o nounset
|
||||||
cd "$flohmarkt_install"
|
cd "$flohmarkt_app_dir"
|
||||||
# initialize_couchdb seems to re-try on connect problems endlessly blocking the yunohost api
|
# initialize_couchdb seems to re-try on connect problems endlessly blocking the yunohost api
|
||||||
# give it 45 seconds to finish and then fail
|
# give it 45 seconds to finish and then fail
|
||||||
# https://codeberg.org/ChriChri/flohmarkt_ynh/issues/13
|
# https://codeberg.org/ChriChri/flohmarkt_ynh/issues/13
|
||||||
|
@ -78,10 +87,10 @@ ynh_script_progression --message="Upgrading flohmarkt couchdb..." --weight=10
|
||||||
|
|
||||||
# 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
|
ynh_add_systemd_config --service=$flohmarkt_filename
|
||||||
# INTEGRATE SERVICE IN YUNOHOST
|
# INTEGRATE SERVICE IN YUNOHOST
|
||||||
ynh_script_progression --message="Integrating service in YunoHost..." --weight=2
|
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
|
# upgrade logrotate
|
||||||
ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1
|
ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1
|
||||||
|
@ -94,10 +103,10 @@ ynh_add_nginx_config
|
||||||
|
|
||||||
# UPGRADE FAIL2BAN
|
# UPGRADE FAIL2BAN
|
||||||
ynh_script_progression --message="Reconfiguring Fail2Ban..." --weight=3
|
ynh_script_progression --message="Reconfiguring Fail2Ban..." --weight=3
|
||||||
ynh_add_fail2ban_config --logpath="/var/log/$app/$app.log" --failregex='INFO: +<HOST>:\d+ - "POST /token HTTP/\d+\.\d+" 403 Forbidden' --max_retry=5
|
ynh_add_fail2ban_config --logpath="$flohmarkt_logfile" --failregex='INFO: +<HOST>:\d+ - "POST /token HTTP/\d+\.\d+" 403 Forbidden' --max_retry=5
|
||||||
|
|
||||||
# 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=$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
|
ynh_script_progression --message="Upgrade of $app completed" --last
|
||||||
|
|
Loading…
Add table
Reference in a new issue