From 2eccb72c139f80c74b0c5faf2a1d709e498ffa14 Mon Sep 17 00:00:00 2001 From: A1EF Date: Mon, 18 Jul 2022 10:46:14 +0300 Subject: [PATCH] Create swap only if not exists yet --- install.sh | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/install.sh b/install.sh index c65bb69..02cf74a 100644 --- a/install.sh +++ b/install.sh @@ -92,12 +92,15 @@ sleep 60 salt-key -a opensourcewebsite.org -y # Swap -fallocate -l 4G /swapfile -chmod 600 /swapfile -mkswap /swapfile -swapon /swapfile -echo '/swapfile none swap sw 0 0' >> /etc/fstab -sysctl vm.swappiness=0 +if ! [[ -f /swapfile ]]; then + fallocate -l 4G /swapfile + chmod 600 /swapfile + mkswap /swapfile + swapon /swapfile + echo '/swapfile none swap sw 0 0' >> /etc/fstab + echo 'vm.swappiness=0' > /etc/sysctl.d/10-swappiness.conf + sysctl --system +fi # Certifications for nginx mkdir -p /etc/letsencrypt/live/opensourcewebsite.org