From d1b22bebfedbb38811007d8f8fe9c02795cd028b Mon Sep 17 00:00:00 2001 From: Eddie Septr Date: Sun, 16 Jun 2019 23:08:56 +0700 Subject: [PATCH] minor update --- scripts/add_repo.sh | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/scripts/add_repo.sh b/scripts/add_repo.sh index 4673a22..e1410ee 100755 --- a/scripts/add_repo.sh +++ b/scripts/add_repo.sh @@ -86,25 +86,27 @@ run apt-get install -y software-properties-common build-essential git unzip cron status "Adding repositories completed..." function create_swap() { - echo "Enabling 1GiB swap..." - L_SWAP_FILE="/lemper-swapfile" - fallocate -l 1G $L_SWAP_FILE && \ - chmod 600 $L_SWAP_FILE && \ - chown root:root $L_SWAP_FILE && \ - mkswap $L_SWAP_FILE && \ - swapon $L_SWAP_FILE + echo "Enabling 1GiB swap..." + + L_SWAP_FILE="/lemper-swapfile" + fallocate -l 1G $L_SWAP_FILE && \ + chmod 600 $L_SWAP_FILE && \ + chown root:root $L_SWAP_FILE && \ + mkswap $L_SWAP_FILE && \ + swapon $L_SWAP_FILE } function check_swap() { - echo -e "\nChecking swap..." - if free | awk '/^Swap:/ {exit !$2}'; then - : - else - warning "No swap detected" - create_swap - fi + echo -e "\nChecking swap..." + + if free | awk '/^Swap:/ {exit !$2}'; then + swapsize=$(free -g | awk '/^Swap:/ { print $2 }') + status "Swap size ${swapsize}GiB." + else + warning "No swap detected" + create_swap + status "Adding swap completed..." + fi } check_swap - -status "Adding swap completed..."