Update setup-auto-updates.sh
This commit is contained in:
@@ -54,17 +54,16 @@ wait_for_apt() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
prompt_update_scope() {
|
prompt_update_scope() {
|
||||||
# Honor env/CI first
|
# Honor env override first (supports: all, full, security)
|
||||||
if [[ -n "$UPDATE_SCOPE" ]]; then
|
if [[ -n "${UPDATE_SCOPE:-}" ]]; then
|
||||||
case "${UPDATE_SCOPE,,}" in
|
case "${UPDATE_SCOPE,,}" in
|
||||||
all|security) ;; # ok
|
all|full) UPDATE_SCOPE="all"; echo "[INFO] Update scope (from env): ALL"; return 0 ;;
|
||||||
*) echo "[ERROR] UPDATE_SCOPE must be 'all' or 'security'"; exit 1 ;;
|
security) UPDATE_SCOPE="security"; echo "[INFO] Update scope (from env): SECURITY-only"; return 0 ;;
|
||||||
|
*) echo "[ERROR] UPDATE_SCOPE must be 'all' (or 'full') or 'security'."; exit 1 ;;
|
||||||
esac
|
esac
|
||||||
echo "[INFO] Update scope (from env): $UPDATE_SCOPE"
|
|
||||||
return 0
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If non-interactive, default to ALL
|
# Non-interactive (no TTY): default to Full
|
||||||
if [[ ! -t 0 ]]; then
|
if [[ ! -t 0 ]]; then
|
||||||
UPDATE_SCOPE="all"
|
UPDATE_SCOPE="all"
|
||||||
echo "[INFO] Non-interactive session: defaulting to ALL updates."
|
echo "[INFO] Non-interactive session: defaulting to ALL updates."
|
||||||
@@ -72,15 +71,24 @@ prompt_update_scope() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo
|
echo
|
||||||
read -r -p "Enable installation of ALL updates (not just security)? [Y/n] " reply
|
echo "Configure automatic updates. Choose one:"
|
||||||
case "$reply" in
|
echo " 1) Full updates — install regular and security updates from your distro"
|
||||||
""|[yY]|[yY][eE][sS]) UPDATE_SCOPE="all" ;;
|
echo " (recommended for most systems; includes -updates and -security pockets)."
|
||||||
[nN]|[nN][oO]) UPDATE_SCOPE="security" ;;
|
echo " 2) Security-only — install only security updates from your distro"
|
||||||
*) UPDATE_SCOPE="all" ;; # default
|
echo " (fewer changes; functional fixes may be delayed)."
|
||||||
esac
|
echo
|
||||||
echo "[INFO] Chosen update scope: $UPDATE_SCOPE"
|
|
||||||
|
while true; do
|
||||||
|
read -r -p "Select [1/2] (default: 1): " choice
|
||||||
|
case "$choice" in
|
||||||
|
""|1) UPDATE_SCOPE="all"; echo "[INFO] Chosen update scope: ALL"; break ;;
|
||||||
|
2) UPDATE_SCOPE="security"; echo "[INFO] Chosen update scope: SECURITY-only"; break ;;
|
||||||
|
*) echo "Please enter 1 or 2."; ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
apt_refresh_and_install() {
|
apt_refresh_and_install() {
|
||||||
wait_for_apt || true
|
wait_for_apt || true
|
||||||
echo "[INFO] Updating APT cache…"
|
echo "[INFO] Updating APT cache…"
|
||||||
|
|||||||
Reference in New Issue
Block a user