Add step_upgrade (apt / paru-yay / pacman)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
+40
-1
@@ -127,11 +127,50 @@ select_target() {
|
||||
done
|
||||
}
|
||||
|
||||
# -----------------------------
|
||||
# Bước 1: Nâng cấp hệ thống theo distro
|
||||
# -----------------------------
|
||||
step_upgrade() {
|
||||
echo "${C_TITLE}--- [System Upgrade] ---${C_RESET}"
|
||||
local distro
|
||||
distro=$(detect_distro)
|
||||
case "$distro" in
|
||||
debian)
|
||||
echo " Distro: Debian/Ubuntu (apt)."
|
||||
sudo apt-get update || { echo "${C_DEL} ✗ apt-get update thất bại.${C_RESET}"; echo ""; return; }
|
||||
local upgradable
|
||||
upgradable=$(apt list --upgradable 2>/dev/null | grep -c 'upgradable')
|
||||
echo " ${C_WARN}✗ ${upgradable} package có thể nâng cấp.${C_RESET}"
|
||||
if confirm_yn "Upgrade + autoremove?"; then
|
||||
sudo apt-get upgrade -y
|
||||
sudo apt-get autoremove --purge -y
|
||||
echo "${C_OK} ✓ Đã nâng cấp xong.${C_RESET}"
|
||||
fi
|
||||
;;
|
||||
arch)
|
||||
echo " Distro: Arch (pacman)."
|
||||
local helper=""
|
||||
command -v paru >/dev/null 2>&1 && helper="paru"
|
||||
[ -z "$helper" ] && command -v yay >/dev/null 2>&1 && helper="yay"
|
||||
[ -z "$helper" ] && helper="sudo pacman"
|
||||
echo " Helper: $helper"
|
||||
if confirm_yn "Chạy $helper -Syu?"; then
|
||||
$helper -Syu
|
||||
echo "${C_OK} ✓ Đã nâng cấp xong.${C_RESET}"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "${C_WARN} ⚠ Distro không hỗ trợ upgrade, bỏ qua.${C_RESET}"
|
||||
;;
|
||||
esac
|
||||
echo ""
|
||||
}
|
||||
|
||||
# -----------------------------
|
||||
# Chạy tuần tự 6 bước (stub — các bước thêm ở Task 4-9)
|
||||
# -----------------------------
|
||||
run_all_steps() {
|
||||
echo " (các bước cleanup sẽ thêm ở Task 4-9)"
|
||||
step_upgrade
|
||||
}
|
||||
|
||||
# -----------------------------
|
||||
|
||||
Reference in New Issue
Block a user