From 58319695dcadb37736cd897b97a97d6574349f2c Mon Sep 17 00:00:00 2001 From: Mollusk Date: Thu, 29 Oct 2026 14:59:00 -0400 Subject: [PATCH] genswap.sh: write swappiness to /etc/sysctl.d and fix fstab check Co-Authored-By: Claude Opus 5.5 --- genswap.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/genswap.sh b/genswap.sh index 2b3b4ee..bcf03e7 100755 --- a/genswap.sh +++ b/genswap.sh @@ -5,7 +5,7 @@ SWAPNAME="swapfile" TOTALRAM=$(free -m | gawk '/Mem:/{print $2}') SWAPPINESS="10" SYSCTLCONF="sysctl.conf" -SYSCTLDIR="sysctl.conf.d" +SYSCTLDIR="sysctl.d" VERSION="0.1.0" BUILDDATE="2018-06-05" @@ -57,7 +57,7 @@ function autoSwap(){ read markswap if [ "${markswap}" = "n" ] || [ "${markswap}" = "N" ];then - echo -e "\n${LCYAN}Not making ${SWAPPATH}/${SWAPFILE} as swap...${NC}\n" + echo -e "\n${LCYAN}Not making ${SWAPPATH}${SWAPNAME} as swap...${NC}\n" else echo -e "\n${LCYAN}Marking ${SWAPPATH}${SWAPNAME} as swap...\n\n${NC}" @@ -80,9 +80,7 @@ function autoSwap(){ echo -e "${LCYAN}Adding ${SWAPPATH}${SWAPNAME} to /etc/fstab ..\n${NC}" echo "${SWAPPATH}${SWAPNAME} none swap sw 0 0" | sudo tee -a /etc/fstab fi - CHECKFSTAB=$(cat /etc/fstab | grep "swap" | gawk '/swap/{print $1}') - - if [ "${CHECKFSTAB}" != "/swapfile" ];then + if ! gawk -v f="${SWAPPATH}${SWAPNAME}" '$1 == f && $3 == "swap" {found=1} END {exit !found}' /etc/fstab;then echo -e "${LRED}Swap line does not exist in /etc/fstab, please manually check this.${NC}\n" else