From 8a00e6375b9c063c27584fd33a03a368744fb711 Mon Sep 17 00:00:00 2001 From: adminroot Date: Sat, 25 Oct 2025 19:27:52 -0700 Subject: [PATCH] revert 1163344ddeab34a162749e547cdce85cb560ee1f MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit revert 更新 setup.sh --- setup.sh | 37 ++++++++++--------------------------- 1 file changed, 10 insertions(+), 27 deletions(-) diff --git a/setup.sh b/setup.sh index 01267e8..2abc53b 100644 --- a/setup.sh +++ b/setup.sh @@ -21,33 +21,16 @@ for choice in $choices; do sysctl -p ;; 2) - while true; do - echo "输入Swap内存大小(MB) [默认: 2048, 5秒后自动使用默认值]: " - if read -t 5 -p "> " swap_size; then - if [ -z "$swap_size" ]; then - swap_size=2048 - echo "使用默认值: ${swap_size}MB" - break - elif [[ "$swap_size" =~ ^[0-9]+$ ]]; then - echo "使用输入的大小: ${swap_size}MB" - break - else - echo "错误: 请输入有效的数字!" - continue - fi - else - swap_size=2048 - echo -e "\n超时, 使用默认值: ${swap_size}MB" - break - fi - done - - echo "执行设置Swap内存大小的脚本..." - dd if=/dev/zero of=/swapfile bs=1M count=$swap_size - mkswap /swapfile - swapon /swapfile - echo "/swapfile swap swap defaults 0 0" | tee -a /etc/fstab - ;; + echo "输入Swap内存大小(MB) [默认: 2G]: " + read -t 5 -p "> " swap_size + if [ $? -ne 0 ] || [ -z "$swap_size" ]; then + echo -e "\n使用默认值: ${swap_size}MB" + fi + dd if=/dev/zero of=/swapfile bs=1M count=$swap_size + mkswap /swapfile + swapon /swapfile + echo "/swapfile swap swap defaults 0 0" | tee -a /etc/fstab + ;; 3) echo "配置常用alias缩写" wget https://git.nvme.cc/adminroot/setup/raw/branch/main/alias.txt -qO ~/.alias.txt