1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/emailpoubelle_ynh.git synced 2024-09-03 18:26:29 +02:00
emailpoubelle_ynh/scripts/upgrade

81 lines
2.7 KiB
Text
Raw Normal View History

2018-11-18 16:00:35 +01:00
#!/bin/bash
2018-11-24 11:27:04 +01:00
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
2022-06-08 03:24:51 +02:00
2018-11-24 11:27:04 +01:00
source _common.sh
source /usr/share/yunohost/helpers
2019-05-20 23:54:52 +02:00
#=================================================
# CHECK VERSION
#=================================================
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
2022-06-08 03:24:51 +02:00
# DOWNLOAD, CHECK AND UNPACK SOURCE
2019-05-20 23:54:52 +02:00
#=================================================
2022-06-08 03:24:51 +02:00
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrading source files..."
2019-05-20 23:54:52 +02:00
2022-06-08 03:24:51 +02:00
# Download, check integrity, uncompress and patch the source from app.src
2023-04-06 13:42:27 +02:00
ynh_setup_source --dest_dir="$install_dir" --keep="conf.php www/index.php"
ynh_add_config --template="../conf/index_source.php" --destination="$install_dir/www/index.php"
2023-04-06 13:48:27 +02:00
ynh_secure_remove --file="$install_dir/www/admin.php"
2022-06-08 03:24:51 +02:00
2023-04-06 13:42:27 +02:00
ln -s $install_dir/lib $install_dir/www/lib
2022-06-08 03:24:51 +02:00
fi
2023-04-06 13:42:27 +02:00
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
2019-05-20 23:54:52 +02:00
#=================================================
2022-06-08 03:24:51 +02:00
# PHP-FPM CONFIGURATION
2019-05-20 23:54:52 +02:00
#=================================================
2022-06-08 03:24:51 +02:00
ynh_script_progression --message="Upgrading PHP-FPM configuration..."
2019-05-20 23:54:52 +02:00
2022-06-08 03:24:51 +02:00
# Create a dedicated PHP-FPM config
2023-04-06 13:54:22 +02:00
ynh_add_fpm_config --usage=low --footprint=low
2018-11-25 16:19:51 +01:00
2019-03-05 22:43:49 +01:00
#=================================================
2022-06-08 03:24:51 +02:00
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..."
2019-05-20 23:54:52 +02:00
2022-06-08 03:24:51 +02:00
# Create a dedicated NGINX config
ynh_add_nginx_config
2019-05-20 23:54:52 +02:00
2022-06-08 03:24:51 +02:00
#=================================================
# SPECIFIC UPGRADE
#=================================================
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Updating a configuration file..."
2023-04-06 14:36:04 +02:00
password=$(ynh_app_setting_get --app=$app --key=password)
2023-04-06 13:42:27 +02:00
ynh_add_config --template="../conf/conf-dist.php" --destination="$install_dir/conf.php"
2022-06-08 03:24:51 +02:00
2023-04-06 13:42:27 +02:00
chmod 400 "$install_dir/conf.php"
chown $app:$app "$install_dir/conf.php"
2018-12-01 11:49:41 +01:00
2019-05-22 12:05:43 +02:00
cp -R ../sources/hooks/conf_regen/98-postfix_emailpoubelle /usr/share/yunohost/hooks/conf_regen/
2019-05-22 12:21:06 +02:00
mv /etc/postfix/main.cf /etc/postfix/main.cf.emailpoubelle.bak
2020-11-01 16:49:03 +01:00
yunohost tools regen-conf postfix -f
2022-06-08 03:24:51 +02:00
ynh_systemd_action --service_name=postfix --action=reload
2019-05-20 23:54:52 +02:00
2022-06-08 03:24:51 +02:00
# Adding cronjob for removing expired email addresses
ynh_add_config --template="../conf/emailpoubelle.cron" --destination="/etc/cron.d/$app"
2020-02-23 16:06:48 +01:00
chown root:root /etc/cron.d/$app
2022-06-08 03:24:51 +02:00
chmod 644 /etc/cron.d/$app
2018-11-18 16:00:35 +01:00
2022-06-08 03:24:51 +02:00
#=================================================
# END OF SCRIPT
#=================================================
2020-11-01 16:49:03 +01:00
2022-06-08 03:24:51 +02:00
ynh_script_progression --message="Upgrade of $app completed"