From 439b4af8b9d526b1a74903e6d855d8905b8d2b42 Mon Sep 17 00:00:00 2001 From: Thomas Lejeune Date: Mon, 25 Apr 2022 06:32:29 -0700 Subject: [PATCH 1/2] Allow disabling SWAP Signed-off-by: Thomas Lejeune --- src/etc/one-context.d/loc-14-mount-swap##one | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/etc/one-context.d/loc-14-mount-swap##one b/src/etc/one-context.d/loc-14-mount-swap##one index 978b3b8..a6ebe1d 100755 --- a/src/etc/one-context.d/loc-14-mount-swap##one +++ b/src/etc/one-context.d/loc-14-mount-swap##one @@ -30,6 +30,6 @@ activate_swaps_linux() { done } -if [ "$(uname -s)" = 'Linux' ]; then +if [ "$(uname -s)" = 'Linux' ] && [ "${DISABLE_SWAP}" != "true" ]; then activate_swaps_linux fi From 0831bdf59d8b38226661a0ea1234c1e219e32a59 Mon Sep 17 00:00:00 2001 From: Thomas Lejeune Date: Tue, 26 Apr 2022 12:53:53 +0200 Subject: [PATCH 2/2] F #260: Add IGNORE_SWAP context param MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Petr OspalĂ˝ --- src/etc/one-context.d/loc-14-mount-swap##one | 23 ++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/etc/one-context.d/loc-14-mount-swap##one b/src/etc/one-context.d/loc-14-mount-swap##one index a6ebe1d..d5425b6 100755 --- a/src/etc/one-context.d/loc-14-mount-swap##one +++ b/src/etc/one-context.d/loc-14-mount-swap##one @@ -21,15 +21,34 @@ if [ "$1" != 'local' ] ; then exit 0 fi +# arg: +is_true() +( + _value=$(echo "$1" | \ + sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' | \ + tr '[:upper:]' '[:lower:]') + case "$_value" in + 1|true|yes|y) + return 0 + ;; + esac + + return 1 +) + activate_swaps_linux() { SWAP_DRIVES=$(blkid -t TYPE="swap" -o device) for SWAP in $SWAP_DRIVES ; do if [ -z "$(swapon -s | grep $SWAP)" ]; then - swapon $SWAP + swapon "$SWAP" fi done } -if [ "$(uname -s)" = 'Linux' ] && [ "${DISABLE_SWAP}" != "true" ]; then +if is_true "${IGNORE_SWAP}" ; then + exit 0 +fi + +if [ "$(uname -s)" = 'Linux' ]; then activate_swaps_linux fi