mirror of
https://github.com/YunoHost-Apps/friendica_ynh.git
synced 2024-09-03 18:36:14 +02:00
111 lines
3.6 KiB
Bash
111 lines
3.6 KiB
Bash
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC START
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source _common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# LOAD SETTINGS
|
|
#=================================================
|
|
ynh_script_progression --message="Loading installation settings..." --weight=1
|
|
|
|
timezone=$(cat /etc/timezone)
|
|
|
|
#=================================================
|
|
# CHECK VERSION
|
|
#=================================================
|
|
|
|
upgrade_type=$(ynh_check_app_version_changed)
|
|
|
|
#=================================================
|
|
# 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"
|
|
|
|
#=================================================
|
|
# CHECK THE PATH
|
|
#=================================================
|
|
ynh_script_progression --message="Ensuring downward compatibility..." --weight=3
|
|
|
|
if [ -f "/etc/cron.d/$app" ]; then
|
|
ynh_secure_remove --file="/etc/cron.d/$app"
|
|
fi
|
|
|
|
# If admin_mail setting doesn't exist, create it
|
|
if [ -z "${email:-}" ]; then
|
|
email=$(ynh_user_get_info --username=$admin --key=mail)
|
|
ynh_app_setting_set --app=$app --key=email --value=$email
|
|
fi
|
|
|
|
# If language setting doesn't exist, create it
|
|
if [ -z "${language:-}" ]; then
|
|
language=en
|
|
ynh_app_setting_set --app=$app --key=language --value=$language
|
|
fi
|
|
|
|
#=================================================
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
#=================================================
|
|
|
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
|
then
|
|
ynh_script_progression --message="Upgrading source files..." --weight=1
|
|
|
|
# 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
|
|
|
|
chmod -R 775 "$install_dir/view/smarty3"
|
|
chmod -R o-rwx "$install_dir"
|
|
chown -R $app:www-data "$install_dir"
|
|
|
|
#=================================================
|
|
# REAPPLY SYSTEM CONFIGURATIONS
|
|
#=================================================
|
|
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
|
|
|
|
# Create a dedicated NGINX config
|
|
ynh_add_nginx_config
|
|
|
|
# Create a dedicated PHP-FPM config
|
|
ynh_add_fpm_config --usage=low --footprint=low
|
|
|
|
ynh_add_systemd_config
|
|
|
|
yunohost service add $app --description="Friendica daemon" --log="/var/log/$app/$app.log"
|
|
|
|
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>\".*$"
|
|
|
|
#=================================================
|
|
# STORE THE CONFIG FILE CHECKSUM
|
|
#=================================================
|
|
|
|
# Run Composer
|
|
pushd "$install_dir"
|
|
ynh_exec_as "$app" php$phpversion bin/composer.phar install --no-dev --quiet
|
|
ynh_exec_as "$app" php$phpversion bin/console dbstructure update
|
|
popd
|
|
|
|
#=================================================
|
|
# 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"
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Upgrade of $app completed" --last
|