1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/mailman3_ynh.git synced 2024-09-03 19:36:17 +02:00
mailman3_ynh/scripts/upgrade

98 lines
3.7 KiB
Bash
Executable file

#!/bin/bash
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..."
ynh_systemd_action --service_name="$app" --action="stop"
ynh_systemd_action --service_name="$app-web" --action="stop"
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
# Create missing db_user_* as copy of db_name_*
if [ -z "$db_user_app" ]; then
db_user_app="$db_name_app"
ynh_app_setting_set --app="$app" --key="db_user_app" --value="$db_user_app"
fi
if [ -z "$db_user_web" ]; then
db_user_web="$db_name_web"
ynh_app_setting_set --app="$app" --key="db_user_web" --value="$db_user_web"
fi
# Migrate rest_admin_* -> rest_api_admin_*
if [ -z "$rest_api_admin_user" ]; then
rest_api_admin_user="$rest_admin_user"
ynh_app_setting_set --app="$app" --key="rest_api_admin_user" --value="$rest_api_admin_user"
ynh_app_setting_delete --app="$app" --key="rest_admin_user"
fi
if [ -z "$rest_api_admin_pwd" ]; then
rest_api_admin_pwd="$rest_admin_pwd"
ynh_app_setting_set --app="$app" --key="rest_api_admin_pwd" --value="$rest_api_admin_pwd"
ynh_app_setting_delete --app="$app" --key="rest_admin_pwd"
fi
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Updating $app's configuration files..."
ynh_add_config --template="mailman.cfg" --destination="/etc/mailman3/mailman.cfg"
chmod 400 "/etc/mailman3/mailman.cfg"
chown list:list "/etc/mailman3/mailman.cfg"
ynh_add_config --template="mailman-hyperkitty.cfg" --destination="/etc/mailman3/mailman-hyperkitty.cfg"
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"
chmod 440 "/etc/mailman3/mailman-web.py"
chown list:www-data "/etc/mailman3/mailman-web.py"
#=================================================
# 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"
#=================================================
# REAPPLY SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
# 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"
#=================================================
# START 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-web" --action=start
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed"