Merge pull request #51 from YunoHost-Apps/testing

Testing
This commit is contained in:
Thomas 2023-12-04 18:17:49 +01:00 committed by GitHub
commit 80ce8920c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 117 additions and 75 deletions

View file

@ -19,7 +19,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in
BookWyrm is a social network for tracking your reading, talking about books, writing reviews, and discovering what to read next. BookWyrm is a social network for tracking your reading, talking about books, writing reviews, and discovering what to read next.
**Shipped version:** 0.6.6~ynh1 **Shipped version:** 0.6.6~ynh2
**Demo:** https://joinbookwyrm.com/fr/ **Demo:** https://joinbookwyrm.com/fr/

View file

@ -19,7 +19,7 @@ Si vous navez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po
BookWyrm est un réseau social pour garder la trace de vos lectures, parler de livres, écrire des critiques et découvrir quoi lire ensuite. BookWyrm est un réseau social pour garder la trace de vos lectures, parler de livres, écrire des critiques et découvrir quoi lire ensuite.
**Version incluse :** 0.6.6~ynh1 **Version incluse :** 0.6.6~ynh2
**Démo :** https://joinbookwyrm.com/fr/ **Démo :** https://joinbookwyrm.com/fr/

View file

@ -47,11 +47,11 @@ FLOWER_PASSWORD=changeme
# Email config # Email config
EMAIL_HOST=localhost EMAIL_HOST=localhost
EMAIL_PORT=587 EMAIL_PORT=587
EMAIL_HOST_USER=__ADMIN_MAIL__ EMAIL_HOST_USER=__APP__
EMAIL_HOST_PASSWORD= EMAIL_HOST_PASSWORD=__MAIL_PWD__
EMAIL_USE_TLS=true EMAIL_USE_TLS=true
EMAIL_USE_SSL=false EMAIL_USE_SSL=false
EMAIL_SENDER_NAME=__ADMIN_MAIL__ EMAIL_SENDER_NAME=__APP__
# defaults to DOMAIN # defaults to DOMAIN
#EMAIL_SENDER_DOMAIN= #EMAIL_SENDER_DOMAIN=

View file

@ -1,7 +1,7 @@
[Unit] [Unit]
Description=__APP__ celery beat process Description=__APP__ celery beat process
After=redis.service postgresql.service After=network.target postgresql.service redis.service
PartOf=__APP__.target PartOf=__APP__.target
[Service] [Service]

View file

@ -1,7 +1,7 @@
[Unit] [Unit]
Description=__APP__ application server Description=__APP__ application server
After=redis.service postgresql.service After=network.target postgresql.service redis.service
PartOf=__APP__.target PartOf=__APP__.target
[Service] [Service]

View file

@ -1,7 +1,7 @@
[Unit] [Unit]
Description=__APP__ celery worker Description=__APP__ celery worker
After=redis.service postgresql.service After=network.target postgresql.service redis.service
PartOf=__APP__.target PartOf=__APP__.target
[Service] [Service]
@ -9,7 +9,7 @@ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__INSTALL_DIR__/ WorkingDirectory=__INSTALL_DIR__/
EnvironmentFile=__INSTALL_DIR__/.env EnvironmentFile=__INSTALL_DIR__/.env
ExecStart=__INSTALL_DIR__/venv/bin/celery -A celerywyrm worker -l info -Q high_priority,medium_priority,low_priority,imports ExecStart=__INSTALL_DIR__/venv/bin/celery -A celerywyrm worker -l info -Q high_priority,medium_priority,low_priority,streams,images,suggested_users,email,connectors,lists,inbox,imports,import_triggered,broadcast,misc
NoNewPrivileges=yes NoNewPrivileges=yes
PrivateTmp=yes PrivateTmp=yes

View file

@ -5,7 +5,7 @@ name = "BookWyrm"
description.en = "Platform for social reading" description.en = "Platform for social reading"
description.fr = "Plateforme de lecture sociale" description.fr = "Plateforme de lecture sociale"
version = "0.6.6~ynh1" version = "0.6.6~ynh2"
maintainers = ["oufmilo"] maintainers = ["oufmilo"]
@ -55,8 +55,13 @@ ram.runtime = "50M"
autoupdate.strategy = "latest_github_tag" autoupdate.strategy = "latest_github_tag"
[resources.sources.fonts]
url = "https://github.com/adobe-fonts/source-han-sans/raw/release/Variable/OTC/SourceHanSans-VF.ttf.ttc"
sha256 = "1662483cf0cdaf04438618fc67e807a00dadb3fd3b4193c3c23cf7ad4dcc499f"
[resources.system_user] [resources.system_user]
allow_email = true
[resources.install_dir] [resources.install_dir]
@ -69,7 +74,7 @@ ram.runtime = "50M"
main.default = 8000 main.default = 8000
[resources.apt] [resources.apt]
packages = "postgresql, postgresql-contrib, python3-venv, libpq-dev, python3-dev" packages = "postgresql, postgresql-contrib, python3-venv, libpq-dev, python3-pip, python3-dev, libpq-dev"
[resources.database] [resources.database]
type = "postgresql" type = "postgresql"

View file

@ -31,9 +31,9 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
# BACKUP SYSTEMD # BACKUP SYSTEMD
#================================================= #=================================================
ynh_backup --src_path="/etc/systemd/system/${app}-beat.service" ynh_backup --src_path="/etc/systemd/system/$app-beat.service"
ynh_backup --src_path="/etc/systemd/system/${app}-server.service" ynh_backup --src_path="/etc/systemd/system/$app-server.service"
ynh_backup --src_path="/etc/systemd/system/${app}-worker.service" ynh_backup --src_path="/etc/systemd/system/$app-worker.service"
ynh_backup --src_path="/etc/systemd/system/$app.target" ynh_backup --src_path="/etc/systemd/system/$app.target"
#================================================= #=================================================

View file

@ -9,9 +9,8 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
admin_mail=$(ynh_user_get_info --username=$admin --key=username)
key=$(ynh_string_random --length=32) key=$(ynh_string_random --length=32)
ynh_app_setting_set --app=$app --key=key --value=$key
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
@ -19,7 +18,8 @@ key=$(ynh_string_random --length=32)
ynh_script_progression --message="Setting up source files..." --weight=1 ynh_script_progression --message="Setting up source files..." --weight=1
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir" ynh_setup_source --dest_dir="$install_dir" --source_id="main"
ynh_setup_source --dest_dir="$install_dir/static/fonts/source_han_sans" --source_id="fonts"
# Set permissions to app files # Set permissions to app files
chmod -R o-rwx "$install_dir" chmod -R o-rwx "$install_dir"
@ -34,8 +34,6 @@ ynh_add_config --template="../conf/.env.production" --destination="$install_dir/
chmod 600 $install_dir/.env chmod 600 $install_dir/.env
chown $app:www-data "$install_dir/.env" chown $app:www-data "$install_dir/.env"
set -a; source "$install_dir/.env"; set +a
mkdir "$install_dir/venv" mkdir "$install_dir/venv"
python3 -m venv "$install_dir/venv" python3 -m venv "$install_dir/venv"
$install_dir/venv/bin/pip3 install -r "$install_dir/requirements.txt" $install_dir/venv/bin/pip3 install -r "$install_dir/requirements.txt"
@ -58,17 +56,29 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=1
# Create a dedicated NGINX config # Create a dedicated NGINX config
ynh_add_nginx_config ynh_add_nginx_config
#=================================================
# LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring logrotate..." --weight=1
# Use logrotate to manage application logfile(s)
ynh_use_logrotate --specific_user=$app
touch /var/log/$app/$app.log
touch /var/log/$app/$app-beat.log
touch /var/log/$app/$app-worker.log
chown -R $app:www-data /var/log/$app/
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
#================================================= #=================================================
ynh_script_progression --message="Configuring a systemd service..." --weight=1 ynh_script_progression --message="Configuring a systemd service..." --weight=1
ynh_add_config --template="../conf/${app}.target" --destination="/etc/systemd/system/$app.target" ynh_add_config --template="../conf/bookwyrm.target" --destination="/etc/systemd/system/$app.target"
# Create a dedicated systemd config # Create a dedicated systemd config
ynh_add_systemd_config --service="${app}-server" --template="${app}-server.service" ynh_add_systemd_config --service="$app-server" --template="bookwyrm-server.service"
ynh_add_systemd_config --service="${app}-worker" --template="${app}-worker.service" ynh_add_systemd_config --service="$app-worker" --template="bookwyrm-worker.service"
ynh_add_systemd_config --service="${app}-beat" --template="${app}-beat.service" ynh_add_systemd_config --service="$app-beat" --template="bookwyrm-beat.service"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
@ -77,9 +87,9 @@ ynh_add_systemd_config --service="${app}-beat" --template="${app}-beat.service
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add "${app}-beat" yunohost service add "$app-beat" --log="/var/log/$app/$app-beat.log"
yunohost service add "${app}-server" yunohost service add "$app-server" --log="/var/log/$app/$app.log"
yunohost service add "${app}-worker" yunohost service add "$app-worker" --log="/var/log/$app/$app-worker.log"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
@ -87,9 +97,9 @@ yunohost service add "${app}-worker"
ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_script_progression --message="Starting a systemd service..." --weight=1
# Start a systemd service # Start a systemd service
ynh_systemd_action --service_name="${app}-beat" --action="start" --log_path="systemd" --line_match="Started" ynh_systemd_action --service_name="$app-beat" --action="start" --log_path="systemd" --line_match="Started"
ynh_systemd_action --service_name="${app}-server" --action="start" --log_path="systemd" --line_match="Booting worker with pid" ynh_systemd_action --service_name="$app-server" --action="start" --log_path="systemd" --line_match="Booting worker with pid"
ynh_systemd_action --service_name="${app}-worker" --action="start" --log_path="systemd" --line_match="ready" ynh_systemd_action --service_name="$app-worker" --action="start" --log_path="systemd" --line_match="ready"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT

View file

@ -9,7 +9,6 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
# STANDARD REMOVE # STANDARD REMOVE
#================================================= #=================================================
@ -17,10 +16,22 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# 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 "$app-server" >/dev/null
then then
ynh_script_progression --message="Removing $app service integration..." --weight=1 ynh_script_progression --message="Removing $app-server service integration..."
yunohost service remove $app yunohost service remove "$app-server"
fi
if ynh_exec_warn_less yunohost service status "$app-worker" >/dev/null
then
ynh_script_progression --message="Removing $app-worker service integration..."
yunohost service remove "$app-worker"
fi
if ynh_exec_warn_less yunohost service status "$app-beat" >/dev/null
then
ynh_script_progression --message="Removing $app-beat service integration..."
yunohost service remove "$app-beat"
fi fi
#================================================= #=================================================
@ -28,25 +39,17 @@ fi
#================================================= #=================================================
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1 ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1
ynh_systemd_action --service_name="${app}-beat" --action="stop" --log_path="systemd" --line_match="Stopped $app" ynh_systemd_action --service_name="$app-beat" --action="stop" --log_path="systemd" --line_match="Stopped $app"
ynh_systemd_action --service_name="${app}-server" --action="stop" --log_path="systemd" --line_match="Stopped $app" ynh_systemd_action --service_name="$app-server" --action="stop" --log_path="systemd" --line_match="Stopped $app"
ynh_systemd_action --service_name="${app}-worker" --action="stop" --log_path="systemd" --line_match="Stopped $app" ynh_systemd_action --service_name="$app-worker" --action="stop" --log_path="systemd" --line_match="Stopped $app"
# Remove the dedicated systemd config # Remove the dedicated systemd config
ynh_remove_systemd_config --service="${app}-beat" ynh_remove_systemd_config --service="$app-beat"
ynh_remove_systemd_config --service="${app}-server" ynh_remove_systemd_config --service="$app-server"
ynh_remove_systemd_config --service="${app}-worker" ynh_remove_systemd_config --service="$app-worker"
ynh_secure_remove --file="/etc/systemd/system/$app.target" ynh_secure_remove --file="/etc/systemd/system/$app.target"
#=================================================
# REMOVE APP MAIN DIR
#=================================================
ynh_script_progression --message="Removing app main directory..." --weight=1
# Remove the app directory securely
ynh_secure_remove --file="$install_dir"
#================================================= #=================================================
# REMOVE NGINX CONFIGURATION # REMOVE NGINX CONFIGURATION
#================================================= #=================================================
@ -55,6 +58,17 @@ ynh_script_progression --message="Removing NGINX web server configuration..." --
# Remove the dedicated NGINX config # Remove the dedicated NGINX config
ynh_remove_nginx_config ynh_remove_nginx_config
#=================================================
# REMOVE LOGS
#=================================================
ynh_script_progression --message="Removing logs..." --weight=5
ynh_remove_logrotate
# Remove the log files
ynh_secure_remove --file="/var/log/$app"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

View file

@ -44,32 +44,32 @@ chown -R $app:www-data "$install_dir"
#================================================= #=================================================
ynh_script_progression --message="Restoring the systemd configuration..." --weight=1 ynh_script_progression --message="Restoring the systemd configuration..." --weight=1
ynh_restore_file --origin_path="/etc/systemd/system/${app}-beat.service" ynh_restore_file --origin_path="/etc/systemd/system/bookwyrm-beat.service"
ynh_restore_file --origin_path="/etc/systemd/system/${app}-server.service" ynh_restore_file --origin_path="/etc/systemd/system/bookwyrm-server.service"
ynh_restore_file --origin_path="/etc/systemd/system/${app}-worker.service" ynh_restore_file --origin_path="/etc/systemd/system/bookwyrm-worker.service"
ynh_restore_file --origin_path="/etc/systemd/system/$app.target" ynh_restore_file --origin_path="/etc/systemd/system/bookwyrm.target"
systemctl enable "${app}-beat.service" --quiet systemctl enable "bookwyrm-beat.service" --quiet
systemctl enable "${app}-server.service" --quiet systemctl enable "bookwyrm-server.service" --quiet
systemctl enable "${app}-worker.service" --quiet systemctl enable "bookwyrm-worker.service" --quiet
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN 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}-beat" yunohost service add "$app-beat" --log="/var/log/$app/$app-beat.log"
yunohost service add "${app}-server" yunohost service add "$app-server" --log="/var/log/$app/$app.log"
yunohost service add "${app}-worker" yunohost service add "$app-worker" --log="/var/log/$app/$app-worker.log"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name="${app}-beat" --action="start" --log_path="systemd" --line_match="Started" ynh_systemd_action --service_name="$app-beat" --action="start" --log_path="systemd" --line_match="Started"
ynh_systemd_action --service_name="${app}-server" --action="start" --log_path="systemd" --line_match="Booting worker with pid" ynh_systemd_action --service_name="$app-server" --action="start" --log_path="systemd" --line_match="Booting worker with pid"
ynh_systemd_action --service_name="${app}-worker" --action="start" --log_path="systemd" --line_match="ready" ynh_systemd_action --service_name="$app-worker" --action="start" --log_path="systemd" --line_match="ready"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION

View file

@ -13,7 +13,11 @@ source /usr/share/yunohost/helpers
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
admin_mail=$(ynh_user_get_info --username=$admin --key=username) # uncomment me after some updates whenever the key variable is set in install for some times
#key=$(ynh_app_setting_get --app=$app --key=key --value=$key)
#remove me when key setting is uncommented (see above)
key=$(ynh_string_random --length=32)
#================================================= #=================================================
# CHECK VERSION # CHECK VERSION
@ -28,9 +32,9 @@ upgrade_type=$(ynh_check_app_version_changed)
#================================================= #=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1 ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_systemd_action --action="stop" --service_name="${app}-beat" --log_path="systemd" --line_match="Stopped" ynh_systemd_action --action="stop" --service_name="bookwyrm-beat" --log_path="systemd" --line_match="Stopped"
ynh_systemd_action --action="stop" --service_name="${app}-server" --log_path="systemd" --line_match="Stopped" ynh_systemd_action --action="stop" --service_name="bookwyrm-server" --log_path="systemd" --line_match="Stopped"
ynh_systemd_action --action="stop" --service_name="${app}-worker" --log_path="systemd" --line_match="Stopped" ynh_systemd_action --action="stop" --service_name="bookwyrm-worker" --log_path="systemd" --line_match="Stopped"
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
@ -41,13 +45,22 @@ then
ynh_script_progression --message="Upgrading source files..." --weight=1 ynh_script_progression --message="Upgrading source files..." --weight=1
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir" --keep=".env" ynh_setup_source --dest_dir="$install_dir" --source_id="main" --keep=".env"
ynh_setup_source --dest_dir="$install_dir/static/fonts/source_han_sans" --source_id="fonts"
fi fi
chmod 750 "$install_dir" chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir" chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir" chown -R $app:www-data "$install_dir"
#=================================================
# CONFIGURE THE INSTALL SCRIPT
#=================================================
ynh_script_progression --message="Upgrading .env file..." --weight=1
ynh_add_config --template="../conf/.env.production" --destination="$install_dir/.env"
chmod 600 $install_dir/.env
chown $app: "$install_dir/.env"
#================================================= #=================================================
# CONFIGURE THEN INSTALL SCRIPT AND DEPENDENCIES # CONFIGURE THEN INSTALL SCRIPT AND DEPENDENCIES
@ -89,12 +102,12 @@ ynh_add_nginx_config
#================================================= #=================================================
ynh_script_progression --message="Upgrading systemd configuration..." --weight=1 ynh_script_progression --message="Upgrading systemd configuration..." --weight=1
ynh_add_config --template="../conf/${app}.target" --destination="/etc/systemd/system/$app.target" ynh_add_config --template="../conf/bookwyrm.target" --destination="/etc/systemd/system/$app.target"
# Create a dedicated systemd config # Create a dedicated systemd config
ynh_add_systemd_config --service="${app}-server" --template="${app}-server.service" ynh_add_systemd_config --service="$app-server" --template="bookwyrm-server.service"
ynh_add_systemd_config --service="${app}-worker" --template="${app}-worker.service" ynh_add_systemd_config --service="$app-worker" --template="bookwyrm-worker.service"
ynh_add_systemd_config --service="${app}-beat" --template="${app}-beat.service" ynh_add_systemd_config --service="$app-beat" --template="bookwyrm-beat.service"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
@ -103,18 +116,18 @@ ynh_add_systemd_config --service="${app}-beat" --template="${app}-beat.service
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add "${app}-beat" yunohost service add "$app-beat" --log="/var/log/$app/$app-beat.log"
yunohost service add "${app}-server" yunohost service add "$app-server" --log="/var/log/$app/$app.log"
yunohost service add "${app}-worker" yunohost service add "$app-worker" --log="/var/log/$app/$app-worker.log"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name="${app}-beat" --action="start" --log_path="systemd" --line_match="Started" ynh_systemd_action --service_name="$app-beat" --action="start" --log_path="systemd" --line_match="Started"
ynh_systemd_action --service_name="${app}-server" --action="start" --log_path="systemd" --line_match="Booting worker with pid" ynh_systemd_action --service_name="$app-server" --action="start" --log_path="systemd" --line_match="Booting worker with pid"
ynh_systemd_action --service_name="${app}-worker" --action="start" --log_path="systemd" --line_match="ready" ynh_systemd_action --service_name="$app-worker" --action="start" --log_path="systemd" --line_match="ready"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT