2017-07-21 21:40:25 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# LOAD SETTINGS
|
|
|
|
#=================================================
|
2023-08-20 15:51:37 +02:00
|
|
|
ynh_script_progression --message="Loading installation settings..." --weight=1
|
|
|
|
|
2022-06-11 10:34:59 +02:00
|
|
|
timezone=$(cat /etc/timezone)
|
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
|
|
|
|
|
|
|
|
# If admin_mail setting doesn't exist, create it
|
2023-08-21 12:18:22 +02:00
|
|
|
if [ -z "${email:-}" ]; then
|
2021-07-17 16:48:02 +02:00
|
|
|
email=$(ynh_user_get_info --username=$admin --key=mail)
|
|
|
|
ynh_app_setting_set --app=$app --key=email --value=$email
|
2018-11-02 15:40:01 +01:00
|
|
|
fi
|
|
|
|
|
2021-07-19 10:28:51 +02:00
|
|
|
# If language setting doesn't exist, create it
|
2023-08-21 12:18:22 +02:00
|
|
|
if [ -z "${language:-}" ]; then
|
2021-07-19 10:28:51 +02:00
|
|
|
language=en
|
|
|
|
ynh_app_setting_set --app=$app --key=language --value=$language
|
|
|
|
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
|
|
|
|
ynh_setup_source --dest_dir="$install_dir" --keep ="config/local.config.php view/smarty3"
|
|
|
|
ynh_setup_source --dest_dir="$install_dir/addon" --source_id="addons"
|
|
|
|
fi
|
2017-07-21 21:40:25 +02:00
|
|
|
|
2023-08-21 09:55:30 +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
|
2021-07-19 10:31:00 +02:00
|
|
|
#ynh_exec_as "$app" bin/console config system addon ldapauth
|
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
|