Last active
March 8, 2021 23:58
-
-
Save lorello/69e16f1c9caa851f1fcbb674d545a109 to your computer and use it in GitHub Desktop.
Unattended upgrades configuration
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
| #!/usr/bin/env bash | |
| set -e | |
| [[ $DEBUG ]] && set -x | |
| conf=/etc/apt/apt.conf.d/50unattended-upgrades | |
| if [[ ! -f $conf ]]; then | |
| echo "Cannot fine /etc/apt/apt.conf.d/50unattended-upgrades, is this an Ubuntu host?" | |
| exit 1 | |
| fi | |
| if [[ ! -f ${conf}.orig ]]; then | |
| echo "Preparing backup before change $conf" | |
| cp ${conf} ${conf}.orig | |
| fi | |
| options="Unattended-Upgrade::MinimalSteps | |
| Unattended-Upgrade::Remove-Unused-Kernel-Packages | |
| Unattended-Upgrade::Remove-Unused-Dependencies" | |
| for option in $options; do | |
| if ! egrep -q "^$option" $conf; then | |
| echo "missing option; $option" | |
| echo "$option \"true\";" >> $conf | |
| fi | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment