9

I have a script that downloads and replaces kernel headers in Debian squeeze.

function fixHeaders(){
    #Replace the kernel headers from OVH with standard kernel headers...
    aptitude -y install linux-image-2.6.32-5-amd64  
    sed s/'GRUB_DEFAULT=0'/'GRUB_DEFAULT=1'/g
    update-grub
    echo "Rebooting the machine. Run this script again after reboot and choose option 2."
    sleep 1
    reboot  
}

The problem I'm having is that after aptitude downloads the package it throws the script into a text gui and asks the user a bunch of questions. Is there any way to skip this or send tab/enter at the appropriate times to select "OK" for all answers?

fuero
  • 9,879
에이바
  • 662

3 Answers3

13

Based on Daniel t's comment I was able to do this with DEBIAN_FRONTEND=noninteractive

DEBIAN_FRONTEND=noninteractive /usr/bin/apt-get install -y -q --force-yes linux-image-2.6.32-5-amd64 
에이바
  • 662
4

Beware that this answer I quote will not get rid of all dialogues, it will still display what APT/DPKG deems critical. Perhaps it's best to experiment with the second option + using the readline frontend for debconf and to prepare an answer file.

Quoting from a sister site:

This should do what you asked; asking the config questions afterward:

$ DEBIAN_PRIORITY=critical
$ export DEBIAN_PRIORITY
$ apt-get upgrade
# Wait a long time.   Should be almost entirely noninteractive.
$ dpkg-reconfigure --default-priority=medium --unseen-only

Alternatively you could try asking all the config questions before:

$ apt-get clean
$ cat >> /etc/apt/apt.conf <<EOF
// Pre-configure all packages before
// they are installed.
DPkg::Pre-Install-Pkgs {
    "dpkg-preconfigure --apt --priority=low";
};
EOF
$ apt-get upgrade
fuero
  • 9,879
0

You can send whatever you want with the tool expect, given that you can identify the "appropriate times" (because the input doesn't change).

Hauke Laging
  • 5,415