Merge pull request #262 from ospalax/add-support-for-ignore-swap

F #260: Add support for `IGNORE_SWAP`
pull/263/head
Petr Ospalý 3 years ago committed by GitHub
commit 3dcc05a406
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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 is_true "${IGNORE_SWAP}" ; then
exit 0
fi
if [ "$(uname -s)" = 'Linux' ]; then if [ "$(uname -s)" = 'Linux' ]; then
activate_swaps_linux activate_swaps_linux
fi fi

Loading…
Cancel
Save