Skip to content

Instantly share code, notes, and snippets.

@lorello
Last active March 8, 2021 23:58
Show Gist options
  • Select an option

  • Save lorello/69e16f1c9caa851f1fcbb674d545a109 to your computer and use it in GitHub Desktop.

Select an option

Save lorello/69e16f1c9caa851f1fcbb674d545a109 to your computer and use it in GitHub Desktop.
Unattended upgrades configuration
#!/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