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

78 lines
2.5 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
2023-11-15 11:26:05 +01:00
ynh_script_progression --message="Upgrading source files..." --weight=1
2020-12-01 12:03:07 +01:00
# Create a temporary directory
2023-11-15 13:32:29 +01:00
#tmpdir="$(mktemp -d)"
2020-12-01 12:03:07 +01:00
# Backup the config file in the temp dir
2023-11-15 13:32:29 +01:00
#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
2023-11-15 13:32:29 +01:00
ynh_setup_source --dest_dir="$install_dir" --keep="data tpl"
2023-11-15 13:32:29 +01:00
#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
2023-11-15 13:32:29 +01:00
#ynh_secure_remove --file="$tmpdir"
2020-12-01 12:03:07 +01:00
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"
2023-11-15 13:32:29 +01:00
#chmod 700 "$install_dir/data/config.json.php"
2018-06-25 05:57:41 +02:00
#=================================================
2023-11-15 11:26:05 +01:00
# REAPPLY SYSTEM CONFIGURATIONS
2018-06-25 05:57:41 +02:00
#=================================================
2023-11-15 11:26:05 +01:00
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
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
# Create a dedicated NGINX config
ynh_add_nginx_config
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
2023-12-12 23:56:13 +01:00
ynh_use_logrotate --logfile="$install_dir/data/log.txt" --non-append --specific_user=$app
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"