From 03b0707a2fbc2e210dc962ece10e9713fe9d126e Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 25 Aug 2021 03:39:10 +0200 Subject: [PATCH] Apply example_ynh --- check_process | 6 ++-- conf/mailman-web.py | 2 +- conf/nginx.conf | 6 ++-- doc/DISCLAIMER.md | 4 --- scripts/backup | 7 +++-- scripts/change_url | 3 -- scripts/install | 30 ++++++++++++++++--- scripts/remove | 16 ++++++++++ scripts/restore | 30 ++++++++++++++----- scripts/upgrade | 15 ++++++++-- ...98-postfix_mailman => 98-postfix_mailman3} | 0 11 files changed, 90 insertions(+), 29 deletions(-) delete mode 100644 scripts/change_url rename sources/hooks/conf_regen/{98-postfix_mailman => 98-postfix_mailman3} (100%) diff --git a/check_process b/check_process index e7b1146..9a38718 100644 --- a/check_process +++ b/check_process @@ -1,7 +1,7 @@ ;; Test complet ; Manifest - domain="domain.tld" (DOMAIN) - is_public=1 (PUBLIC|public=1|private=0) + domain="domain.tld" + is_public=1 ; Checks pkg_linter=1 setup_sub_dir=0 @@ -13,7 +13,7 @@ backup_restore=1 multi_instance=0 port_already_use=1 - change_url=1 + change_url=0 ;;; Options Email= Notification=none diff --git a/conf/mailman-web.py b/conf/mailman-web.py index 3f2f558..197984c 100644 --- a/conf/mailman-web.py +++ b/conf/mailman-web.py @@ -134,7 +134,7 @@ EMAILNAME = '__DOMAIN__' # otherwise the emails may get rejected. # https://docs.djangoproject.com/en/1.8/ref/settings/#default-from-email # DEFAULT_FROM_EMAIL = "mailing-lists@you-domain.org" -DEFAULT_FROM_EMAIL = 'postorius@{}'.format(EMAILNAME) +DEFAULT_FROM_EMAIL = 'root@{}'.format(EMAILNAME) # If you enable email reporting for error messages, this is where those emails # will appear to be coming from. Make sure you set a valid domain name, diff --git a/conf/nginx.conf b/conf/nginx.conf index de08d50..2f11c13 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,11 +1,11 @@ location / { include /etc/nginx/uwsgi_params; uwsgi_pass unix:/run/mailman3-web/uwsgi.sock; - include conf.d/yunohost_panel.conf.inc; + #include conf.d/yunohost_panel.conf.inc; } -location /mailman3/static { - alias /var/lib/mailman3/web/static; +location /mailman3/static/ { + alias /var/lib/mailman3/web/static/; } location /mailman3/static/favicon.ico { diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md index 5f11883..0359a49 100644 --- a/doc/DISCLAIMER.md +++ b/doc/DISCLAIMER.md @@ -1,9 +1,5 @@ * Any known limitations, constrains or stuff not working, such as (but not limited to): * requiring a full dedicated domain - * architectures not supported ? - * not-working single-sign on or LDAP integration ? - * the app requires an important amount of RAM / disk / .. to install or to work properly - * etc... * Other infos that people should be aware of, such as: * No LDAP support yet (apparently under development) diff --git a/scripts/backup b/scripts/backup index e8f2cd4..6034411 100755 --- a/scripts/backup +++ b/scripts/backup @@ -44,12 +44,15 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # SPECIFIC BACKUP - #================================================= # BACKUP VARIOUS FILES #================================================= -ynh_backup --src_path="/etc/$app" +ynh_backup --src_path="/etc/$app/mailman.cfg" +ynh_backup --src_path="/etc/$app/mailman-hyperkitty.cfg" +ynh_backup --src_path="/etc/$app/mailman-web.py" + +ynh_backup --src_path="/usr/share/yunohost/hooks/conf_regen/98-postfix_mailman3" #================================================= # BACKUP THE POSTGRESQL DATABASE diff --git a/scripts/change_url b/scripts/change_url deleted file mode 100644 index c7e9ab4..0000000 --- a/scripts/change_url +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -# TODO(decentral1se) diff --git a/scripts/install b/scripts/install index 1e05e73..83e1b30 100755 --- a/scripts/install +++ b/scripts/install @@ -128,6 +128,9 @@ secret_key=$(head -n64 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c6 ynh_app_setting_set --app=$app --key=secret_key --value="$secret_key" ynh_add_config --template="../conf/mailman-web.py" --destination="/etc/mailman3/mailman-web.py" +chmod 440 "/etc/mailman3/mailman-web.py" +chown list:www-data "/etc/mailman3/mailman-web.py" + #================================================= # RUN DATABASE MIGRATIONS #================================================= @@ -137,6 +140,25 @@ pushd /usr/share/mailman3-web python3 manage.py migrate || ynh_die --message="Mailman3 migrations failed!" popd +#================================================= +# POSTFIX CONFIGURATION +#================================================= +ynh_script_progression --message="Configuring postfix mail server..." + +# Add postfix configuration hook and regen postfix conf +cp -R ../sources/hooks/conf_regen/98-postfix_mailman3 /usr/share/yunohost/hooks/conf_regen/ +yunohost tools regen-conf postfix +ynh_systemd_action --service_name=postfix --action="restart" + +#================================================= +# SETUP SYSTEMD +#================================================= +ynh_script_progression --message="Configuring a systemd service..." + +# Create a dedicated systemd config +systemctl enable $app.service --quiet +systemctl enable "$app-web".service --quiet + #================================================= # GENERIC FINALIZATION #================================================= @@ -144,8 +166,8 @@ popd #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $app --description="Mailman3 daemon" -yunohost service add "$app-web" --description="Mailman3 web daemon" +yunohost service add $app --description="Mailman3 daemon" --log="/var/log/$app/mailman.log" +yunohost service add "$app-web" --description="Mailman3 web daemon" --log="/var/log/$app/web/mailman-web.log" #================================================= # START SYSTEMD SERVICE @@ -153,8 +175,8 @@ yunohost service add "$app-web" --description="Mailman3 web daemon" ynh_script_progression --message="Starting a systemd service..." # Start a systemd service -ynh_systemd_action --service_name=$app --action="start" -ynh_systemd_action --service_name="$app-web" --action="start" +ynh_systemd_action --service_name=$app --action="restart" +ynh_systemd_action --service_name="$app-web" --action="restart" #================================================= # SETUP SSOWAT diff --git a/scripts/remove b/scripts/remove index 5f50a44..50c6050 100755 --- a/scripts/remove +++ b/scripts/remove @@ -43,6 +43,17 @@ then yunohost service remove "$app-web" fi +#================================================= +# STOP AND REMOVE SERVICE +#================================================= +ynh_script_progression --message="Stopping and removing the systemd service..." + +# Remove the dedicated systemd config +ynh_systemd_action --service_name=$app --action="stop" +systemctl disable $app.service --quiet +ynh_systemd_action --service_name="$app-web" --action="stop" +systemctl disable "$app-web".service --quiet + #================================================= # REMOVE THE POSTGRESQL DATABASE #================================================= @@ -80,6 +91,11 @@ ynh_secure_remove --file="/usr/share/mailman3-web" # Remove a directory securely ynh_secure_remove --file="/etc/$app" +# Remove hook for postfix conf +ynh_secure_remove --file="/usr/share/yunohost/hooks/conf_regen/98-postfix_mailman3" +yunohost tools regen-conf postfix +ynh_systemd_action --service_name=postfix --action="restart" + #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/restore b/scripts/restore index 0dcc81c..0a6dc43 100755 --- a/scripts/restore +++ b/scripts/restore @@ -83,15 +83,34 @@ ynh_psql_execute_file_as_root --file="./db_web.sql" --database=$db_name_web #================================================= ynh_script_progression --message="Restoring various files..." -ynh_restore_file --origin_path="/etc/$app/" +ynh_restore_file --origin_path="/usr/share/yunohost/hooks/conf_regen/98-postfix_mailman3" +yunohost tools regen-conf postfix +ynh_systemd_action --service_name=postfix --action="restart" + +ynh_secure_remove --file="/etc/$app/mailman.cfg" +ynh_restore_file --origin_path="/etc/$app/mailman.cfg" + +ynh_secure_remove --file="/etc/$app/mailman-hyperkitty.cfg" +ynh_restore_file --origin_path="/etc/$app/mailman-hyperkitty.cfg" + +ynh_secure_remove --file="/etc/$app/mailman-web.py" +ynh_restore_file --origin_path="/etc/$app/mailman-web.py" + +#================================================= +# RESTORE SYSTEMD +#================================================= +ynh_script_progression --message="Restoring the systemd configuration..." + +systemctl enable $app.service --quiet +systemctl enable "$app-web".service --quiet #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $app --description="Mailman3 daemon" -yunohost service add "$app-web" --description="Mailman3 web daemon" +yunohost service add $app --description="Mailman3 daemon" --log="/var/log/$app/mailman.log" +yunohost service add "$app-web" --description="Mailman3 web daemon" --log="/var/log/$app/web/mailman-web.log" #================================================= # START SYSTEMD SERVICE @@ -99,16 +118,13 @@ yunohost service add "$app-web" --description="Mailman3 web daemon" ynh_script_progression --message="Starting a systemd service..." # Start a systemd service -ynh_systemd_action --service_name=$app --action=enable -ynh_systemd_action --service_name="$app-web" --action=enable - ynh_systemd_action --service_name=$app --action=restart ynh_systemd_action --service_name="$app-web" --action=restart #================================================= # GENERIC FINALIZATION #================================================= -# RELOAD NGINX AND PHP-FPM +# RELOAD NGINX #================================================= ynh_script_progression --message="Reloading NGINX web server..." diff --git a/scripts/upgrade b/scripts/upgrade index 88284ef..391e017 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -36,6 +36,7 @@ ynh_script_progression --message="Backing up the app before upgrading (may take # Backup the current version of the app ynh_backup_before_upgrade ynh_clean_setup () { + ynh_clean_check_starting # Restore it if the upgrade fails ynh_restore_upgradebackup } @@ -79,6 +80,16 @@ ynh_script_progression --message="Upgrading dependencies..." ynh_install_app_dependencies $pkg_dependencies +#================================================= +# POSTFIX CONFIGURATION +#================================================= +ynh_script_progression --message="Configuring postfix mail server..." + +# Add postfix configuration hook and regen postfix conf +cp -R ../sources/hooks/conf_regen/98-postfix_mailman3 /usr/share/yunohost/hooks/conf_regen/ +yunohost tools regen-conf postfix +ynh_systemd_action --service_name=postfix --action="reload" + #================================================= # GENERIC FINALIZATION #================================================= @@ -86,8 +97,8 @@ ynh_install_app_dependencies $pkg_dependencies #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $app --description="Mailman3 daemon" -yunohost service add "$app-web" --description="Mailman3 web daemon" +yunohost service add $app --description="Mailman3 daemon" --log="/var/log/$app/mailman.log" +yunohost service add "$app-web" --description="Mailman3 web daemon" --log="/var/log/$app/web/mailman-web.log" #================================================= # START SYSTEMD SERVICE diff --git a/sources/hooks/conf_regen/98-postfix_mailman b/sources/hooks/conf_regen/98-postfix_mailman3 similarity index 100% rename from sources/hooks/conf_regen/98-postfix_mailman rename to sources/hooks/conf_regen/98-postfix_mailman3