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"
|
|
|
|
|
2018-09-28 18:25:44 +02:00
|
|
|
#=================================================
|
|
|
|
# CHECK THE PATH
|
|
|
|
#=================================================
|
2021-09-26 20:10:18 +02:00
|
|
|
ynh_script_progression --message="Ensuring downward compatibility..." --weight=3
|
|
|
|
|
2023-08-21 12:18:22 +02:00
|
|
|
if [ -f "/etc/cron.d/$app" ]; then
|
2023-08-21 12:18:06 +02:00
|
|
|
ynh_secure_remove --file="/etc/cron.d/$app"
|
2019-03-12 11:37:22 +01:00
|
|
|
fi
|
|
|
|
|
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 13:50:20 +02:00
|
|
|
ynh_setup_source --dest_dir="$install_dir" --keep ="config/local.config.php " #view/smarty3
|
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-21 13:50:20 +02:00
|
|
|
#chmod -R 775 "$install_dir/view/smarty3"
|
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-08-20 15:51:37 +02:00
|
|
|
ynh_add_fpm_config --usage=low --footprint=low
|
2020-04-09 10:42:49 +02:00
|
|
|
|
2023-08-21 10:05:52 +02:00
|
|
|
ynh_add_systemd_config
|
|
|
|
|
|
|
|
yunohost service add $app --description="Friendica daemon" --log="/var/log/$app/$app.log"
|
|
|
|
|
2023-08-21 12:34:53 +02:00
|
|
|
ynh_use_logrotate --non-append
|
|
|
|
|
|
|
|
# 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-08-21 12:34:53 +02:00
|
|
|
ynh_exec_as "$app" php$phpversion bin/console dbstructure update
|
2020-10-15 21:09:24 +02:00
|
|
|
popd
|
2017-07-21 21:40:25 +02:00
|
|
|
|
2023-08-21 10:05:52 +02:00
|
|
|
#=================================================
|
|
|
|
# START SYSTEMD SERVICE
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
|
|
|
|
|
|
|
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
|
|
|
|
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
|