genswap.sh: add check for swap in fstab

Former-commit-id: e5118bf5caf09ddc170589acd2a28a2e17956b3b
This commit is contained in:
mollusk 2018-09-19 02:55:54 -07:00
parent 70725bfc6d
commit 9b82f6d234

View File

@ -65,10 +65,19 @@ function autoSwap(){
fi fi
echo -e "\n${LCYAN}Creating backup of /etc/fstab ...\n${NC}" 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 -e "${LCYAN}Adding ${SWAPPATH}${SWAPNAME} to /etc/fstab ..\n${NC}"
echo "${SWAPPATH}${SWAPNAME} none swap sw 0 0" | sudo tee -a /etc/fstab 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(){ function swappiness(){
@ -110,7 +119,7 @@ function help(){
} }
function version(){ function version(){
echo -e "Version ${VERSION}, built: ${BUILDDATE}\n" echo -e "Version ${VERSION}, Build Date: ${BUILDDATE}\n"
} }
case "${1}" in case "${1}" in