F #260: Add IGNORE_SWAP context param

Signed-off-by: Petr Ospalý <pospaly@opennebula.io>
pull/262/head
Thomas Lejeune 3 years ago committed by Petr Ospalý
parent 439b4af8b9
commit 0831bdf59d
No known key found for this signature in database
GPG Key ID: 96B7C54C30DA9F72

@ -21,15 +21,34 @@ if [ "$1" != 'local' ] ; then
exit 0 exit 0
fi fi
# arg: <true|yes|false|no>
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() { activate_swaps_linux() {
SWAP_DRIVES=$(blkid -t TYPE="swap" -o device) SWAP_DRIVES=$(blkid -t TYPE="swap" -o device)
for SWAP in $SWAP_DRIVES ; do for SWAP in $SWAP_DRIVES ; do
if [ -z "$(swapon -s | grep $SWAP)" ]; then if [ -z "$(swapon -s | grep $SWAP)" ]; then
swapon $SWAP swapon "$SWAP"
fi fi
done 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 activate_swaps_linux
fi fi

Loading…
Cancel
Save