From 00498fdac6bc61dc5b89f2c328cff1557bd6505a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Tille?= Date: Tue, 23 Aug 2022 06:24:57 +0200 Subject: [PATCH] Fix swap from upstream --- scripts/_common.sh | 2 +- scripts/experimental_helper.sh | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 23c78f1..dd45e7c 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -34,7 +34,7 @@ install_dependance() { memcached libmemcached-dev \ python3-scipy python3-matplotlib \ libjpeg62-turbo-dev zlib1g-dev # For building pillow - ynh_add_swap 2000 + ynh_add_swap --size=2000 # We need to do that because we can have some issue about the permission access to the pip cache without this chown -R $seafile_user:$seafile_user $final_path diff --git a/scripts/experimental_helper.sh b/scripts/experimental_helper.sh index 717906f..ae0188e 100644 --- a/scripts/experimental_helper.sh +++ b/scripts/experimental_helper.sh @@ -1,3 +1,5 @@ +#!/bin/bash + # Add swap # # usage: ynh_add_swap --size=SWAP in Mb @@ -46,6 +48,12 @@ ynh_add_swap () { # If there's enough space for a swap, and no existing swap here if [ $swap_size -ne 0 ] && [ ! -e /swap_$app ] then + # Create file + truncate -s 0 /swap_$app + + # set the No_COW attribute on the swapfile with chattr + chattr +C /swap_$app + # Preallocate space for the swap file, fallocate may sometime not be used, use dd instead in this case if ! fallocate -l ${swap_size}K /swap_$app then @@ -68,7 +76,7 @@ ynh_del_swap () { # Clean the fstab sed -i "/#Swap added by $app/d" /etc/fstab # Desactive the swap file - swapoff /swap_$app || true + swapoff /swap_$app # And remove it rm /swap_$app fi @@ -89,4 +97,3 @@ ynh_is_main_device_a_sd_card () { return 1 fi } -