2017-07-21 21:40:25 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
2020-04-09 10:42:49 +02:00
|
|
|
#=================================================
|
|
|
|
# CHECK VERSION
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
upgrade_type=$(ynh_check_app_version_changed)
|
2017-07-21 21:40:25 +02:00
|
|
|
|
2023-08-21 10:05:52 +02:00
|
|
|
#=================================================
|
|
|
|
# STOP SYSTEMD SERVICE
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Stopping a systemd service..." --weight=1
|
|
|
|
|
|
|
|
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
|
|
|
|
|
2020-04-09 10:42:49 +02:00
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
|
|
|
then
|
2023-08-21 09:55:30 +02:00
|
|
|
ynh_script_progression --message="Upgrading source files..." --weight=1
|
2018-09-28 18:25:44 +02:00
|
|
|
|
2023-08-21 09:55:30 +02:00
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
2023-08-21 14:08:27 +02:00
|
|
|
ynh_setup_source --dest_dir="$install_dir" --keep="config/local.config.php"
|
2023-08-21 09:55:30 +02:00
|
|
|
ynh_setup_source --dest_dir="$install_dir/addon" --source_id="addons"
|
|
|
|
fi
|
2017-07-21 21:40:25 +02:00
|
|
|
|
2023-08-20 15:36:10 +02:00
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R $app:www-data "$install_dir"
|
2017-07-21 21:40:25 +02:00
|
|
|
|
2019-03-12 11:37:22 +01:00
|
|
|
#=================================================
|
2023-08-21 12:34:53 +02:00
|
|
|
# REAPPLY SYSTEM CONFIGURATIONS
|
2019-03-12 11:37:22 +01:00
|
|
|
#=================================================
|
2023-08-21 12:34:53 +02:00
|
|
|
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
|
2019-03-12 11:37:22 +01:00
|
|
|
|
2021-07-19 08:38:46 +02:00
|
|
|
# Create a dedicated NGINX config
|
2017-07-21 21:40:25 +02:00
|
|
|
ynh_add_nginx_config
|
|
|
|
|
2021-07-19 08:38:46 +02:00
|
|
|
# Create a dedicated PHP-FPM config
|
2023-09-11 18:06:52 +02:00
|
|
|
ynh_add_fpm_config
|
2020-04-09 10:42:49 +02:00
|
|
|
|
2023-08-21 12:34:53 +02:00
|
|
|
ynh_use_logrotate --non-append
|
|
|
|
|
2023-09-11 18:06:24 +02:00
|
|
|
ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
|
|
|
|
chown root: "/etc/cron.d/$app"
|
|
|
|
chmod 644 "/etc/cron.d/$app"
|
|
|
|
|
2023-08-21 12:34:53 +02:00
|
|
|
# Create a dedicated Fail2Ban config
|
|
|
|
ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="^.*authenticate\: failed login attempt.*\"ip\"\:\"<HOST>\".*$"
|
|
|
|
|
2020-04-09 10:42:49 +02:00
|
|
|
#=================================================
|
|
|
|
# STORE THE CONFIG FILE CHECKSUM
|
|
|
|
#=================================================
|
|
|
|
|
2021-07-19 10:31:00 +02:00
|
|
|
# Run Composer
|
2023-08-20 15:36:10 +02:00
|
|
|
pushd "$install_dir"
|
2021-07-19 09:16:19 +02:00
|
|
|
ynh_exec_as "$app" php$phpversion bin/composer.phar install --no-dev --quiet
|
2023-09-12 21:41:20 +02:00
|
|
|
ynh_exec_as "$app" php$phpversion bin/console.php dbstructure update
|
2020-10-15 21:09:24 +02:00
|
|
|
popd
|
2017-07-21 21:40:25 +02:00
|
|
|
|
2019-03-12 11:37:22 +01:00
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2021-07-19 08:38:46 +02:00
|
|
|
ynh_script_progression --message="Upgrade of $app completed" --last
|