Skip to content
This repository was archived by the owner on Jan 16, 2024. It is now read-only.

Commit 0831bdf

Browse files
Thomas Lejeuneospalax
authored andcommitted
F #260: Add IGNORE_SWAP context param
Signed-off-by: Petr Ospalý <pospaly@opennebula.io>
1 parent 439b4af commit 0831bdf

1 file changed

Lines changed: 21 additions & 2 deletions

File tree

src/etc/one-context.d/loc-14-mount-swap##one

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,34 @@ if [ "$1" != 'local' ] ; then
2121
exit 0
2222
fi
2323

24+
# arg: <true|yes|false|no>
25+
is_true()
26+
(
27+
_value=$(echo "$1" | \
28+
sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' | \
29+
tr '[:upper:]' '[:lower:]')
30+
case "$_value" in
31+
1|true|yes|y)
32+
return 0
33+
;;
34+
esac
35+
36+
return 1
37+
)
38+
2439
activate_swaps_linux() {
2540
SWAP_DRIVES=$(blkid -t TYPE="swap" -o device)
2641
for SWAP in $SWAP_DRIVES ; do
2742
if [ -z "$(swapon -s | grep $SWAP)" ]; then
28-
swapon $SWAP
43+
swapon "$SWAP"
2944
fi
3045
done
3146
}
3247

33-
if [ "$(uname -s)" = 'Linux' ] && [ "${DISABLE_SWAP}" != "true" ]; then
48+
if is_true "${IGNORE_SWAP}" ; then
49+
exit 0
50+
fi
51+
52+
if [ "$(uname -s)" = 'Linux' ]; then
3453
activate_swaps_linux
3554
fi

0 commit comments

Comments
 (0)