Ubuntu dpkg, non interactive installation

I am trying to install a bunch of .deb files without having to interact with them. MySQL Server for example will prompt for an interactive menu to enter an administrative password upon the dpkg's configuration.

I have tried.

export DEBIAN_FRONTEND=noninteractive && export DEBIAN_PRIORITY=critical && sudo /usr/bin/dpkg -i ./files/*

I am aware that I can just extract the files without configuration. I am trying to create a bash script to deploy a server pre-configured of default installation of Apache, php, mySQL etc. However, this "interactive installation" is causing issues.

Any ideas on how to disable it? or a work around?

Thanks


Solution 1:

You are on the right track. You definitely want to use DEBIAN_FRONTEND=noninteractive. For critical questions that cannot be ignored, you will want to preseed the debconf database with the necessary answers. The debconf man page has all the details about how to accomplish that.

Solution 2:

For general noninteractive frontend, you may try:

sudo dpkg-reconfigure debconf -f noninteractive -p critical

To configure MySQL credentials, you may use server configuration file (e.g. ~/.my.cnf), like:

[client]
user=root
password=root

To select some specific selections, use debconf-set-selections, e.g.:

echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | sudo debconf-set-selections