#!/usr/bin/env bash
set -euo pipefail

if [ "$(id -u)" -ne 0 ]; then
  echo "Jalankan sebagai root."
  exit 1
fi

read -rp "Aktifkan automatic security updates? [Y/n]: " CONFIRM
CONFIRM="${CONFIRM:-Y}"
if [[ ! "$CONFIRM" =~ ^[Yy]$ ]]; then
  echo "Dibatalkan."
  exit 0
fi

apt update
apt -y install unattended-upgrades apt-listchanges
dpkg-reconfigure -f noninteractive unattended-upgrades
systemctl enable --now unattended-upgrades
echo "Automatic security update aktif."
