1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/ttrss_ynh.git synced 2024-10-01 13:34:46 +02:00

Fix upgrade (don't keep deleted files from older upstream versions)

This commit is contained in:
Jimmy Monin 2019-03-17 12:34:20 +01:00
parent 291fc4715a
commit 3c2240a9cd
2 changed files with 40 additions and 2 deletions

View file

@ -14,3 +14,29 @@ ynh_delete_file_checksum () {
local checksum_setting_name=checksum_${1//[\/ ]/_} # Replace all '/' and ' ' by '_'
ynh_app_setting_delete $app $checksum_setting_name
}
ynh_smart_mktemp () {
local min_size="${1:-300}"
# Transform the minimum size from megabytes to kilobytes
min_size=$(( $min_size * 1024 ))
# Check if there's enough free space in a directory
is_there_enough_space () {
local free_space=$(df --output=avail "$1" | sed 1d)
test $free_space -ge $min_size
}
if is_there_enough_space /tmp; then
local tmpdir=/tmp
elif is_there_enough_space /var; then
local tmpdir=/var
elif is_there_enough_space /; then
local tmpdir=/
elif is_there_enough_space /home; then
local tmpdir=/home
else
ynh_die "Insufficient free space to continue..."
fi
echo "$(sudo mktemp --directory --tmpdir="$tmpdir")"
}

View file

@ -6,7 +6,7 @@
# IMPORT GENERIC HELPERS
#=================================================
# source _common.sh
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
@ -64,8 +64,11 @@ path_url=$(ynh_normalize_url_path $path_url)
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
# Create a temporary directory
tmpdir="$(ynh_smart_mktemp 10)"
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source "$final_path"
ynh_setup_source "$tmpdir"
#=================================================
# NGINX CONFIGURATION
@ -99,6 +102,14 @@ ynh_add_fpm_config
# CONFIGURE TTRSS
#=================================================
# Backup the config file in the temp dir
cp -a "$final_path/config.php" "$tmpdir/config.php"
# Replace the old ttrss by the new one
ynh_secure_remove "$final_path"
mv "$tmpdir" "$final_path"
ynh_secure_remove "$tmpdir"
# Verify the checksum and backup the file if it's different
ynh_backup_if_checksum_is_different "$final_path/config.php"
@ -126,6 +137,7 @@ sudo -u $app php ${final_path}/update.php --update-schema
# Set permissions to app files
chown -R root: $final_path
chmod 0755 $final_path
chown -R $app $final_path/{cache,feed-icons,lock}
#=================================================