include swappiness prompt in auto option
Former-commit-id: 4b5b2774df4c368d35ecc58d69a948550f717440 Former-commit-id: ff7742940ee611123e976c348d276e21548bd50b
This commit is contained in:
parent
37618793de
commit
87b08c6235
31
genswap.sh
31
genswap.sh
@ -48,11 +48,11 @@ function autoSwap(){
|
||||
|
||||
sleep 1
|
||||
|
||||
echo -e -n "\n${YELLOW}Do you want to mark ${SWAPPATH}${SWAPNAME} as swap?(Y/n): ${NC}"
|
||||
echo -e -n "\n${YELLOW}Do you want to mark ${SWAPPATH}${SWAPNAME} as swap now?(Y/n): ${NC}"
|
||||
read markswap
|
||||
|
||||
if [ "${markswap}" = "n" ] || [ "${markswap}" = "N" ];then
|
||||
exit 0
|
||||
echo "\n${LCYAN}Not making ${SWAPPATH}/${SWAPFILE} as swap...${NC}\n"
|
||||
fi
|
||||
|
||||
echo -e "\n${LCYAN}Marking ${SWAPPATH}${SWAPNAME} as swap...\n\n${NC}"
|
||||
@ -65,7 +65,7 @@ function autoSwap(){
|
||||
read addfstab
|
||||
|
||||
if [ "${addfstab}" = "n" ];then
|
||||
exit 0
|
||||
echo -e "\n${LCYAN} Not adding ${SWAPPATH}${SWAPNAME} to fstab${NC}\n"
|
||||
fi
|
||||
|
||||
echo -e "\n${LCYAN}Creating backup of /etc/fstab ...\n${NC}"
|
||||
@ -76,9 +76,8 @@ function autoSwap(){
|
||||
|
||||
CHECKFSTAB=$(cat /etc/fstab | grep "swap" | gawk '/swap/{print $2}')
|
||||
|
||||
if [ $CHECKFSTAB != "swap" ];then
|
||||
if [ "${CHECKFSTAB}" != "swap" ];then
|
||||
echo -e "${LRED}Swap line does not exist in /etc/fstab, please manually check this.${NC}\n"
|
||||
exit 1
|
||||
|
||||
else
|
||||
echo -e "${LGREEN}Swap successfully added to /etc/fstab! Reboot to verify success...${NC}\n"
|
||||
@ -93,12 +92,12 @@ function autoSwap(){
|
||||
|
||||
sudo reboot
|
||||
else
|
||||
exit 0
|
||||
echo -e "\n${LGREEN}Swapfile setup complete, setting swappiness level...${NC}\n"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function swappiness(){
|
||||
function setSwappinessLvl(){
|
||||
|
||||
|
||||
echo -e -n "\n${YELLOW}Enter a number for swappiness (0-100)[default=10]: ${NC}"
|
||||
@ -177,6 +176,22 @@ case "${1}" in
|
||||
|
||||
-a|--auto)
|
||||
autoSwap
|
||||
|
||||
while true;do
|
||||
echo -e "\n${YELLOW}Do you want to set the swappiness level?(y/n):${NC} "
|
||||
read swappinessLevel
|
||||
|
||||
if [ "${swappinessLevel}" = "y" ];then
|
||||
setSwappinessLvl
|
||||
break && exit 0;
|
||||
|
||||
elif [ "${swappinessLevel}" = "n" ];then
|
||||
break && exit 0;
|
||||
|
||||
else
|
||||
echo -e "\n${LRED}Please enter 'y' or 'n'${NC}\n"
|
||||
fi
|
||||
done
|
||||
;;
|
||||
|
||||
-v|version|--version)
|
||||
@ -184,7 +199,7 @@ case "${1}" in
|
||||
;;
|
||||
|
||||
-s|--swappiness)
|
||||
swappiness
|
||||
setSwappinessLvl
|
||||
;;
|
||||
|
||||
*)
|
||||
|
Loading…
x
Reference in New Issue
Block a user