Skip to content

Commit

Permalink
F OpenNebula#260: Add IGNORE_SWAP context param
Browse files Browse the repository at this point in the history
Signed-off-by: Petr Ospalý <[email protected]>
  • Loading branch information
Th0masL authored and Petr Ospalý committed May 3, 2022
1 parent 0700e68 commit a9d95cb
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/etc/one-context.d/loc-14-mount-swap##one
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,34 @@ if [ "$1" != 'local' ] ; then
exit 0
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() {
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

0 comments on commit a9d95cb

Please sign in to comment.