helpers: rewrite ynh_del_swap with a variable swap file location.

This commit is contained in:
Salamandar 2024-05-31 16:25:14 +02:00 committed by Salamandar
parent 2aa14345fe
commit 0e90430419

View file

@ -190,16 +190,20 @@ ynh_add_swap () {
# [packagingv1] # [packagingv1]
# #
ynh_del_swap () { ynh_del_swap () {
# If there a swap at this place # Could be moved to an argument
if [ -e /swap_file ] swapfile_dir="$(realpath /)"
then swapfile_path="$(realpath "$swapfile_dir/swap_file")"
# Clean the fstab
sed -i "/#Swap added by YunoHost config panel/d" /etc/fstab if [ ! -f "$swapfile_path" ]; then
# Desactive the swap file return
swapoff /swap_file
# And remove it
rm /swap_file
fi fi
# Clean the fstab...
sed -i "/#Swap added by $app/d" /etc/fstab
# Desactive the swap file...
swapoff "$swapfile_path"
# And remove it.
rm "$swapfile_path"
} }
# Check if the device of the provided directory is an SD card # Check if the device of the provided directory is an SD card