mirror of
https://github.com/YunoHost-Apps/mailman3_ynh.git
synced 2024-09-03 19:36:17 +02:00
Finalize packaging v2
This commit is contained in:
parent
bcc3451494
commit
96047337fc
4 changed files with 47 additions and 183 deletions
|
@ -1,7 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC START
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -10,40 +8,17 @@
|
||||||
source ../settings/scripts/_common.sh
|
source ../settings/scripts/_common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# MANAGE SCRIPT FAILURE
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
#REMOVEME? ynh_clean_setup () {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
# Exit if an error occurs during the execution of the script
|
|
||||||
#REMOVEME? ynh_abort_if_errors
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# LOAD SETTINGS
|
|
||||||
#=================================================
|
|
||||||
#REMOVEME? ynh_print_info --message="Loading installation settings..."
|
|
||||||
|
|
||||||
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
|
||||||
|
|
||||||
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
|
|
||||||
#REMOVEME? db_name_app=$(ynh_app_setting_get --app=$app --key=db_name_app)
|
|
||||||
#REMOVEME? db_name_web=$(ynh_app_setting_get --app=$app --key=db_name_web)
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info --message="Declaring files to be backed up..."
|
ynh_print_info --message="Declaring files to be backed up..."
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE NGINX CONFIGURATION
|
# SYSTEM CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SPECIFIC BACKUP
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP VARIOUS FILES
|
# BACKUP VARIOUS FILES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -10,8 +10,8 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# SANITY CHECK
|
# SANITY CHECK
|
||||||
#=================================================
|
#=================================================
|
||||||
test ! -e /usr/share/$app-web || ynh_die --message="Mailman3 is already installed!"
|
test ! -e "/usr/share/$app-web" || ynh_die --message="Mailman3 is already installed!"
|
||||||
test ! -e /etc/$app || ynh_die --message="Mailman3 is already installed!"
|
test ! -e "/etc/$app" || ynh_die --message="Mailman3 is already installed!"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# INITIALIZE AND STORE SETTINGS
|
# INITIALIZE AND STORE SETTINGS
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC START
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -11,75 +9,28 @@ source ../settings/scripts/_common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# MANAGE SCRIPT FAILURE
|
# SANITY CHECK
|
||||||
#=================================================
|
#=================================================
|
||||||
|
test ! -e "/usr/share/$app-web" || ynh_die --message="Mailman3 is already installed!"
|
||||||
#REMOVEME? ynh_clean_setup () {
|
test ! -e "/etc/$app" || ynh_die --message="Mailman3 is already installed!"
|
||||||
ynh_clean_check_starting
|
|
||||||
}
|
|
||||||
# Exit if an error occurs during the execution of the script
|
|
||||||
#REMOVEME? ynh_abort_if_errors
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# LOAD SETTINGS
|
|
||||||
#=================================================
|
|
||||||
#REMOVEME? ynh_script_progression --message="Loading installation settings..."
|
|
||||||
|
|
||||||
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
|
||||||
|
|
||||||
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
|
|
||||||
#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path)
|
|
||||||
#REMOVEME? db_name_app=$(ynh_app_setting_get --app=$app --key=db_name_app)
|
|
||||||
db_user_app=$db_name_app
|
|
||||||
#REMOVEME? db_name_web=$(ynh_app_setting_get --app=$app --key=db_name_web)
|
|
||||||
db_user_web=$db_name_web
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# CHECK IF THE APP CAN BE RESTORED
|
|
||||||
#=================================================
|
|
||||||
#REMOVEME? ynh_script_progression --message="Validating restoration parameters..."
|
|
||||||
|
|
||||||
test ! -d /usr/share/mailman3-web \
|
|
||||||
|| ynh_die --message="There is already an installation present at /usr/share/mailman3-web?"
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# STANDARD RESTORATION STEPS
|
|
||||||
#=================================================
|
|
||||||
# RESTORE THE NGINX CONFIGURATION
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Restoring the NGINX web server configuration..."
|
|
||||||
|
|
||||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SPECIFIC RESTORATION
|
|
||||||
#=================================================
|
|
||||||
# REINSTALL DEPENDENCIES
|
|
||||||
#=================================================
|
|
||||||
#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..."
|
|
||||||
|
|
||||||
# Define and install dependencies
|
|
||||||
#REMOVEME? ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE POSTGRESQL DATABASE
|
# RESTORE THE POSTGRESQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
#REMOVEME? ynh_script_progression --message="Restoring the PostgreSQL database..."
|
ynh_script_progression --message="Restoring the PostgreSQL database..."
|
||||||
|
|
||||||
#REMOVEME? ynh_psql_test_if_first_run
|
ynh_psql_test_if_first_run
|
||||||
|
|
||||||
#REMOVEME? db_pwd_app=$(ynh_app_setting_get --app=$app --key=db_pwd_app)
|
ynh_psql_setup_db --db_user="$db_user_app" --db_name="$db_name_app" --db_pwd="$db_pwd_app"
|
||||||
#REMOVEME? ynh_psql_setup_db --db_user=$db_user_app --db_name=$db_name_app --db_pwd=$db_pwd_app
|
ynh_psql_execute_file_as_root --file="./db_app.sql" --database="$db_name_app"
|
||||||
ynh_psql_execute_file_as_root --file="./db_app.sql" --database=$db_name_app
|
|
||||||
|
|
||||||
#REMOVEME? db_pwd_web=$(ynh_app_setting_get --app=$app --key=db_pwd_web)
|
ynh_psql_setup_db --db_user="$db_user_web" --db_name="$db_name_web" --db_pwd="$db_pwd_web"
|
||||||
#REMOVEME? ynh_psql_setup_db --db_user=$db_user_web --db_name=$db_name_web --db_pwd=$db_pwd_web
|
ynh_psql_execute_file_as_root --file="./db_web.sql" --database="$db_name_web"
|
||||||
ynh_psql_execute_file_as_root --file="./db_web.sql" --database=$db_name_web
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE VARIOUS FILES
|
# RESTORE VARIOUS FILES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring various files..."
|
ynh_script_progression --message="Restoring $app's configuration files..."
|
||||||
|
|
||||||
ynh_restore_file --origin_path="/usr/share/yunohost/hooks/conf_regen/98-postfix_mailman3"
|
ynh_restore_file --origin_path="/usr/share/yunohost/hooks/conf_regen/98-postfix_mailman3"
|
||||||
yunohost tools regen-conf postfix
|
yunohost tools regen-conf postfix
|
||||||
|
@ -95,37 +46,26 @@ ynh_secure_remove --file="/etc/$app/mailman-web.py"
|
||||||
ynh_restore_file --origin_path="/etc/$app/mailman-web.py"
|
ynh_restore_file --origin_path="/etc/$app/mailman-web.py"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE SYSTEMD
|
# RESTORE SYSTEM CONFIGURATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring the systemd configuration..."
|
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
|
||||||
|
|
||||||
systemctl enable $app.service --quiet
|
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
systemctl enable "$app-web".service --quiet
|
|
||||||
|
|
||||||
#=================================================
|
systemctl enable "$app.service" --quiet
|
||||||
# INTEGRATE SERVICE IN YUNOHOST
|
systemctl enable "$app-web.service" --quiet
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Integrating service in YunoHost..."
|
|
||||||
|
|
||||||
yunohost service add $app --description="Mailman3 daemon" --log="/var/log/$app/mailman.log"
|
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"
|
yunohost service add "$app-web" --description="Mailman3 web daemon" --log="/var/log/$app/web/mailman-web.log"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SYSTEMD SERVICE
|
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Starting a systemd service..."
|
ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1
|
||||||
|
|
||||||
# Start a systemd service
|
ynh_systemd_action --service_name="$app" --action=restart
|
||||||
ynh_systemd_action --service_name=$app --action=restart
|
|
||||||
ynh_systemd_action --service_name="$app-web" --action=restart
|
ynh_systemd_action --service_name="$app-web" --action=restart
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC FINALIZATION
|
|
||||||
#=================================================
|
|
||||||
# RELOAD NGINX
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Reloading NGINX web server..."
|
|
||||||
|
|
||||||
ynh_systemd_action --service_name=nginx --action=reload
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
101
scripts/upgrade
101
scripts/upgrade
|
@ -1,7 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC START
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -9,76 +7,30 @@
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# LOAD SETTINGS
|
|
||||||
#=================================================
|
|
||||||
#REMOVEME? ynh_script_progression --message="Loading installation settings..."
|
|
||||||
|
|
||||||
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
|
||||||
|
|
||||||
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
|
|
||||||
#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path)
|
|
||||||
#REMOVEME? db_name_app=$(ynh_app_setting_get --app=$app --key=db_name_app)
|
|
||||||
#REMOVEME? db_name_web=$(ynh_app_setting_get --app=$app --key=db_name_web)
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# CHECK VERSION
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Checking version..."
|
|
||||||
|
|
||||||
upgrade_type=$(ynh_check_app_version_changed)
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
|
||||||
#=================================================
|
|
||||||
#REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..."
|
|
||||||
|
|
||||||
# Backup the current version of the app
|
|
||||||
#REMOVEME? ynh_backup_before_upgrade
|
|
||||||
#REMOVEME? ynh_clean_setup () {
|
|
||||||
ynh_clean_check_starting
|
|
||||||
# Restore it if the upgrade fails
|
|
||||||
#REMOVEME? ynh_restore_upgradebackup
|
|
||||||
}
|
|
||||||
# Exit if an error occurs during the execution of the script
|
|
||||||
#REMOVEME? ynh_abort_if_errors
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# STANDARD UPGRADE STEPS
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STOP SYSTEMD SERVICE
|
# STOP SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Stopping a systemd service..."
|
ynh_script_progression --message="Stopping a systemd service..."
|
||||||
|
|
||||||
ynh_systemd_action --service_name=$app --action="stop"
|
ynh_systemd_action --service_name="$app" --action="stop"
|
||||||
ynh_systemd_action --service_name="$app-web" --action=stop
|
ynh_systemd_action --service_name="$app-web" --action="stop"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# ENSURE DOWNWARD COMPATIBILITY
|
# ADD A CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Ensuring downward compatibility..."
|
ynh_script_progression --message="Updating $app's configuration files..."
|
||||||
|
|
||||||
# Cleaning legacy permissions
|
ynh_add_config --template="mailman.cfg" --destination="/etc/mailman3/mailman.cfg"
|
||||||
#REMOVEME? if ynh_legacy_permissions_exists; then
|
chmod 400 "/etc/mailman3/mailman.cfg"
|
||||||
#REMOVEME? ynh_legacy_permissions_delete_all
|
chown list:list "/etc/mailman3/mailman.cfg"
|
||||||
|
|
||||||
ynh_app_setting_delete --app=$app --key=is_public
|
ynh_add_config --template="mailman-hyperkitty.cfg" --destination="/etc/mailman3/mailman-hyperkitty.cfg"
|
||||||
fi
|
chmod 400 "/etc/mailman3/mailman-hyperkitty.cfg"
|
||||||
|
chown list:list "/etc/mailman3/mailman-hyperkitty.cfg"
|
||||||
|
|
||||||
#=================================================
|
ynh_add_config --template="mailman-web.py" --destination="/etc/mailman3/mailman-web.py"
|
||||||
# NGINX CONFIGURATION
|
chmod 440 "/etc/mailman3/mailman-web.py"
|
||||||
#=================================================
|
chown list:www-data "/etc/mailman3/mailman-web.py"
|
||||||
ynh_script_progression --message="Upgrading NGINX web server configuration..."
|
|
||||||
|
|
||||||
# Create a dedicated NGINX config
|
|
||||||
ynh_add_nginx_config
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# UPGRADE DEPENDENCIES
|
|
||||||
#=================================================
|
|
||||||
#REMOVEME? ynh_script_progression --message="Upgrading dependencies..."
|
|
||||||
|
|
||||||
#REMOVEME? ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# POSTFIX CONFIGURATION
|
# POSTFIX CONFIGURATION
|
||||||
|
@ -88,33 +40,30 @@ ynh_script_progression --message="Configuring postfix mail server..."
|
||||||
# Add postfix configuration hook and regen postfix conf
|
# Add postfix configuration hook and regen postfix conf
|
||||||
cp -R ../sources/hooks/conf_regen/98-postfix_mailman3 /usr/share/yunohost/hooks/conf_regen/
|
cp -R ../sources/hooks/conf_regen/98-postfix_mailman3 /usr/share/yunohost/hooks/conf_regen/
|
||||||
yunohost tools regen-conf postfix
|
yunohost tools regen-conf postfix
|
||||||
ynh_systemd_action --service_name=postfix --action="reload"
|
ynh_systemd_action --service_name="postfix" --action="reload"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# REAPPLY SYSTEM CONFIGURATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
# INTEGRATE SERVICE IN YUNOHOST
|
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Integrating service in YunoHost..."
|
|
||||||
|
|
||||||
yunohost service add $app --description="Mailman3 daemon" --log="/var/log/$app/mailman.log"
|
# Create a dedicated NGINX config
|
||||||
|
ynh_add_nginx_config
|
||||||
|
|
||||||
|
systemctl enable "$app.service" --quiet
|
||||||
|
systemctl enable "$app-web.service" --quiet
|
||||||
|
|
||||||
|
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"
|
yunohost service add "$app-web" --description="Mailman3 web daemon" --log="/var/log/$app/web/mailman-web.log"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SYSTEMD SERVICE
|
# START SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Starting a systemd service..."
|
ynh_script_progression --message="Starting $app's systemd service..." --weight=1
|
||||||
|
|
||||||
ynh_systemd_action --service_name=$app --action=start
|
ynh_systemd_action --service_name="$app" --action=start
|
||||||
ynh_systemd_action --service_name="$app-web" --action=start
|
ynh_systemd_action --service_name="$app-web" --action=start
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RELOAD NGINX
|
|
||||||
#=================================================
|
|
||||||
#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..."
|
|
||||||
|
|
||||||
#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
Loading…
Reference in a new issue