Skip to content

Commit 2eccb72

Browse files
committed
Create swap only if not exists yet
1 parent e20b0cb commit 2eccb72

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

install.sh

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,15 @@ sleep 60
9292
salt-key -a opensourcewebsite.org -y
9393

9494
# Swap
95-
fallocate -l 4G /swapfile
96-
chmod 600 /swapfile
97-
mkswap /swapfile
98-
swapon /swapfile
99-
echo '/swapfile none swap sw 0 0' >> /etc/fstab
100-
sysctl vm.swappiness=0
95+
if ! [[ -f /swapfile ]]; then
96+
fallocate -l 4G /swapfile
97+
chmod 600 /swapfile
98+
mkswap /swapfile
99+
swapon /swapfile
100+
echo '/swapfile none swap sw 0 0' >> /etc/fstab
101+
echo 'vm.swappiness=0' > /etc/sysctl.d/10-swappiness.conf
102+
sysctl --system
103+
fi
101104

102105
# Certifications for nginx
103106
mkdir -p /etc/letsencrypt/live/opensourcewebsite.org

0 commit comments

Comments
 (0)