Skip to content

Instantly share code, notes, and snippets.

@amotl
Last active March 16, 2022 21:27
Show Gist options
  • Select an option

  • Save amotl/5097e39b065ec495e42ec6982c99f930 to your computer and use it in GitHub Desktop.

Select an option

Save amotl/5097e39b065ec495e42ec6982c99f930 to your computer and use it in GitHub Desktop.
Enable Debian Unattended Security Upgrades
#!/bin/bash
set +ex
# Get target email address from STDIN
STDIN=$(cat -)
# File to place custom configuration parameters into
CUSTOM_CONFIG_FILE=/etc/apt/apt.conf.d/80custom
# Install prerequisites
apt-get --yes install unattended-upgrades apt-listchanges
#EMAIL_ADDRESS=test@example.org
# Configure email address
EMAIL_ADDRESS=$STDIN
if [ ! -z ${EMAIL_ADDRESS} ]; then
cat ${CUSTOM_CONFIG_FILE} | grep ${EMAIL_ADDRESS}
if [ $? -gt 0 ]; then
printf "\nUnattended-Upgrade::Mail \"${EMAIL_ADDRESS}\";\n" >> ${CUSTOM_CONFIG_FILE}
fi
fi
# Activate unattended upgrades
echo unattended-upgrades unattended-upgrades/enable_auto_updates boolean true | debconf-set-selections
dpkg-reconfigure -f noninteractive unattended-upgrades
# Manually run unattended upgrades once
apt-get update && unattended-upgrade -d
@amotl
Copy link
Copy Markdown
Author

amotl commented Mar 16, 2022

This program has just been converged into a dedicated repository at https://github.com/cicerops/autopilot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment