Last active
March 16, 2022 21:27
-
-
Save amotl/5097e39b065ec495e42ec6982c99f930 to your computer and use it in GitHub Desktop.
Enable Debian Unattended Security Upgrades
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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 |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This program has just been converged into a dedicated repository at https://github.com/cicerops/autopilot.