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

95 lines
3.1 KiB
Text
Raw Normal View History

2013-12-19 03:02:51 +01:00
#!/bin/bash
2018-06-25 05:57:41 +02:00
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# CHECK VERSION
#=================================================
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ] || [ "$upgrade_type" == "UPGRADE_FORCED" ] # we should do that during a force upgrade too (as it could lead to a version upgrade for instance)
then
2020-11-24 16:08:48 +01:00
ynh_script_progression --message="Upgrading source files..."
2020-12-01 12:03:07 +01:00
# Create a temporary directory
tmpdir="$(mktemp -d)"
# Backup the config file in the temp dir
cp -a "$install_dir/data" "$tmpdir/data"
cp -a "$install_dir/tpl" "$tmpdir/tpl"
2020-12-01 12:03:07 +01:00
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir"
cp -a "$tmpdir/data" "$install_dir/"
cp -a -n "$tmpdir/tpl" "$install_dir/" # copy without erasing existing templates (from official source)
2018-06-25 05:57:41 +02:00
2020-12-01 12:03:07 +01:00
# Remove the tmp directory securely
ynh_secure_remove --file="$tmpdir"
fi
2018-06-25 05:57:41 +02:00
chmod -R o-rwx "$install_dir"
chmod -R u+rwX $install_dir/{cache/,data/,pagecache/,tmp/}
chown -R $app:www-data "$install_dir"
chmod 700 "$install_dir/data/config.json.php"
2018-06-25 05:57:41 +02:00
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
2020-11-24 18:00:33 +01:00
ynh_script_progression --message="Upgrading PHP-FPM configuration..."
2018-06-25 05:57:41 +02:00
# Create a dedicated PHP-FPM config
2023-11-15 11:17:59 +01:00
ynh_add_fpm_config
2018-06-25 05:57:41 +02:00
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..."
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# GENERIC FINALIZATION
2018-09-27 22:44:34 +02:00
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Upgrading logrotate configuration..."
2018-09-27 22:44:34 +02:00
# Use logrotate to manage app-specific logfile(s)
# Temporary fix for .txt log file and ynh_use_logrotate
if [ -d "$install_dir/data/log.txt" ]
2019-09-26 14:21:49 +02:00
then
ynh_secure_remove "$install_dir/data/log.txt"
touch "$install_dir/data/log.txt"
2019-09-26 14:21:49 +02:00
fi
chown $app:www-data "$install_dir/data/log.txt"
2020-12-01 12:03:07 +01:00
ynh_use_logrotate --non-append --specific_user=$app
2018-09-27 22:44:34 +02:00
#=================================================
# UPGRADE FAIL2BAN
2018-09-27 22:44:34 +02:00
#=================================================
2020-11-24 18:00:33 +01:00
ynh_script_progression --message="Reconfiguring Fail2Ban..."
2018-09-27 22:44:34 +02:00
2020-12-01 13:35:39 +01:00
# Create a dedicated Fail2Ban config
ynh_add_fail2ban_config --logpath="$install_dir/data/log.txt" --failregex="\s-\s<HOST>\s-\sLogin failed for user.*$"
2018-06-25 05:57:41 +02:00
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed"