Update setup-auto-updates.sh
This commit is contained in:
@@ -150,6 +150,25 @@ show_status() {
|
||||
fi
|
||||
}
|
||||
|
||||
prompt_self_delete() {
|
||||
# Only prompt on an interactive TTY
|
||||
if [[ -t 0 ]]; then
|
||||
echo
|
||||
read -r -p "Script successful. Do you wish to delete this script? [y/N] " reply
|
||||
case "$reply" in
|
||||
[yY]|[yY][eE][sS])
|
||||
echo "[INFO] Removing script: $0"
|
||||
rm -- "$0" 2>/dev/null || echo "[WARN] Could not delete $0 (permission or filesystem issue)."
|
||||
;;
|
||||
*)
|
||||
echo "[INFO] Keeping script: $0"
|
||||
;;
|
||||
esac
|
||||
else
|
||||
echo "[INFO] Non-interactive session; skipping delete prompt."
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
echo "[INFO] Unattended-upgrades configurator (Debian/Ubuntu)"
|
||||
require_root
|
||||
@@ -184,6 +203,9 @@ main() {
|
||||
show_status
|
||||
echo
|
||||
echo "[OK] Unattended updates configured. Regular + security updates will apply automatically; reboot at ${REBOOT_TIME} if needed."
|
||||
|
||||
# Offer to remove the script itself
|
||||
prompt_self_delete
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
||||
Reference in New Issue
Block a user