How to do apt upgrade with noninteractive?
I want make Ubuntu 18.04 server (text only) upgrade itself and keep original configure in a bash script. I tried
apt update && apt upgrade -y
and
apt-get -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" dist-upgrade
and
apt upgrade --yes --force-yes
and
export DEBIAN_FRONTEND=noninteractive
apt-get -o Dpkg::Options::="--force-confold" upgrade -q -y --force-yes
ALL not working which means they all ask for interactive.
Solution 1:
Finally I make a script that works.
This will try upgrade everything and keep the configuration file,
Only safe for flash installed box.
#!/bin/bash
sudo apt update -y
export DEBIAN_FRONTEND=noninteractive
sudo -E apt-get -o Dpkg::Options::="--force-confold" -o Dpkg::Options::="--force-confdef" dist-upgrade -q -y --allow-downgrades --allow-remove-essential --allow-change-held-packages