File tree Expand file tree Collapse file tree
modules/app_stack/scripts Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -18,8 +18,32 @@ command -v docker >/dev/null
1818command -v blkid > /dev/null
1919command -v mkfs.ext4 > /dev/null
2020command -v mountpoint > /dev/null
21+ command -v swapon > /dev/null
22+ command -v mkswap > /dev/null
23+
24+ ensure_swap () {
25+ local swap_file=" /swapfile"
26+
27+ if ! swapon --show=NAME --noheadings | grep -Fxq " $swap_file " ; then
28+ if [ ! -f " $swap_file " ]; then
29+ fallocate -l 2G " $swap_file " || dd if=/dev/zero of=" $swap_file " bs=1M count=2048
30+ fi
31+
32+ chmod 600 " $swap_file "
33+ if [ " $( blkid -s TYPE -o value " $swap_file " 2> /dev/null || true) " != " swap" ]; then
34+ mkswap " $swap_file "
35+ fi
36+
37+ swapon " $swap_file "
38+ fi
39+
40+ if ! grep -Eq " ^[^#][[:space:]]*$swap_file [[:space:]]+none[[:space:]]+swap[[:space:]]" /etc/fstab; then
41+ printf ' %s none swap sw 0 0\n' " $swap_file " >> /etc/fstab
42+ fi
43+ }
2144
2245systemctl enable docker
46+ ensure_swap
2347
2448DATA_VOLUME_ID=" ${db_data_volume_id} "
2549DATA_VOLUME_SERIAL=" $( printf ' %s' " $DATA_VOLUME_ID " | tr -d ' -' ) "
You can’t perform that action at this time.
0 commit comments