Automate apt update and keep current config files

When doing update on a Debian/Ubuntu server, if a package is trying to modify a config file, it’s asking for a manual choice. If you’re trying to try to automate the process, you’d probably like to get rid of that ask and keep the current config file by default.

For that, you can use that script:

#!/bin/bash
apt-get update
listUpgrades=`apt list --upgradable |grep upgradable |cut -d/ -f1`
execUpgrades="DEBIAN_FRONTEND=noninteractive apt-get --yes --assume-yes -o DPkg::options::=\"--force-confdef\" -o DPkg::options::=\"--force-confold\" --only-upgrade install "$listUpgrades
eval $execUpgrades

The multiple options will enforce the update to keep current config and not overwrite it with the package default one.