Debian – Unable to force Debian to do unattended install… libc6 wants interactive confirm

aptautomated-installdebiandpkglibc6

I'm trying to create a script that forces a Debian Lenny install to install the latest version of CRAN R. During the install it appears libc6 is upgraded and the install wants interactive confirm that it's OK to restart three services (mysql, exim4, cron). This process HAS to be unattended as it runs on Amazon's Elastic Map Reduce (EMR) machines. But I'm running out of options. Here's a few things I've tried:

This previous question appears to be exactly what I'm looking for. So I set up my install script as follows:

# set my CRAN repos... yes, I know there's a new convention where to put these. 
echo "deb http://cran.r-project.org/bin/linux/debian lenny-cran/" | sudo tee -a /etc/apt/sources.list
echo "deb-src http://cran.r-project.org/bin/linux/debian lenny-cran/" | sudo tee -a /etc/apt/sources.list

# set the dpkg.cfg options per the previous SuperUser question
echo "force-confold" | sudo tee -a  /etc/dpkg/dpkg.cfg
echo "force-confdef" | sudo tee -a  /etc/dpkg/dpkg.cfg
export DEBIAN_FRONTEND=noninteractive

# add key to keyring so it doesn't complain 
gpg --keyserver pgp.mit.edu --recv-key 381BA480
gpg -a --export 381BA480 > jranke_cran.asc
sudo apt-key add jranke_cran.asc

sudo apt-get update

# install the latest R
sudo apt-get install --yes --force-yes r-base 

But this script hangs with the following request for input:

enter image description here

OK, so I tried stopping the services using the following script:

sudo /etc/init.d/mysql stop
sudo /etc/init.d/exim4 stop
sudo /etc/init.d/cron stop
sudo apt-get install --yes --force-yes libc6

This does not work and the interactive screen comes back, but this time with only cron listed as the service that must be restarted.

So is there a way to make libc6 just restart these services with no user input? Or is there a way to stop cron so it does not cause an interactive prompt? Maybe a creative option I've never thought of?

Keep in mind that this system is brought up, some Hadoop code is run, and then it's torn down. So I can put up with side effects and bad behavior that we might not want in a production desktop machine or web server.

Best Answer

I'm not positive on the settings in Lenny but I know that in Squeeze, sudo is configured with env_reset meaning it will strip out all but a very few select env variables before running the command.

This means the DEBIAN_FRONTEND variable you set is never actually making it to the apt-get install --yes --force-yes r-base. If you have full access to sudo, meaning you are in the sudoers files with ALL = ALL permissions, then you can override this behavior.

Try using the following instead.

sudo DEBIAN_FRONTEND=noninteractive apt-get install --yes --force-yes r-base

Edit: Note that rewriting the script to not use sudo everywhere and instead run the script as root would also work. But doing that would just be avoiding the real problem I pointed out instead of solving it and learning from it.