From 9b82f6d234f943841a992863530d1d3ba41a46c2 Mon Sep 17 00:00:00 2001 From: mollusk Date: Wed, 19 Sep 2018 02:55:54 -0700 Subject: [PATCH] genswap.sh: add check for swap in fstab Former-commit-id: e5118bf5caf09ddc170589acd2a28a2e17956b3b --- genswap.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/genswap.sh b/genswap.sh index 3d91445..713608b 100755 --- a/genswap.sh +++ b/genswap.sh @@ -65,10 +65,19 @@ function autoSwap(){ fi echo -e "\n${LCYAN}Creating backup of /etc/fstab ...\n${NC}" - sudo cp /etc/fstab /etc/fstab.bak + sudo cp -v /etc/fstab /etc/fstab.bak echo -e "${LCYAN}Adding ${SWAPPATH}${SWAPNAME} to /etc/fstab ..\n${NC}" echo "${SWAPPATH}${SWAPNAME} none swap sw 0 0" | sudo tee -a /etc/fstab + + CHECKFSTAB=$(cat /etc/fstab | grep "swap" | gawk '/swap/{print $2}') + + if [ ! $CHECKFSTAB ];then + echo -e "${LRED}Swap line does not exist in /etc/fstab, please manually check this.${NC}\n" + + else + echo -e "${LGREEN}Swap successfully added to /etc/fstab! Please reboot your machine...${NC}\n" + fi } function swappiness(){ @@ -110,7 +119,7 @@ function help(){ } function version(){ - echo -e "Version ${VERSION}, built: ${BUILDDATE}\n" + echo -e "Version ${VERSION}, Build Date: ${BUILDDATE}\n" } case "${1}" in