Bash – apt-get -y upgrade keep asking me to confirm keep /tmp/grub.xC3mMKP0zx file and i can’t skip it

bashshell-scriptUbuntu

We have automated build bash script
where at the beginning executed command

apt-get update;
apt-get upgrade -q -y -u 
  --allow-downgrades --allow-remove-essential --allow-change-held-packages 
  --allow-change-held-packages --allow-unauthenticated;

but it keeps asking this question with popup in terminal

A new version (/tmp/grub.xC3mMKP0zx) of configuration file /etc/default/grub is available, but the version installed currently has been locally modified.

enter image description here

which is reason that automated script execution is hanging and i can't force skip it somehow with –allow* or -y options

our ubuntu is 16.04

how i kan avoid that popup appearce ?

Please help, Thanks

— UPDATE —

I have tried many solutions
also this one: Force non-interactive "dpkg –configure" when using apt-get install which was mentioned as duplicate to this question

apt-get -o DPkg::Options::=--force-confdef upgrade -q -y -u --force-yes

it still the same promt popup asking for choose default option

Best Answer

I found DEBIAN_FRONTEND=noninteractive option here: https://superuser.com/questions/164553/automatically-answer-yes-when-using-apt-get-install

And only combination of DEBIAN_FRONTEND=noninteractive and Dpkg::Options::="--force-confdef" prevented that option popup to open

So the final command is

apt-get update;
DEBIAN_FRONTEND=noninteractive apt-get upgrade -q -y -u  -o 
   Dpkg::Options::="--force-confdef" --allow-downgrades 
   --allow-remove-essential --allow-change-held-packages 
   --allow-change-held-packages --allow-unauthenticated;
Related Question