14

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

3

3 Answers 3

9

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.

2
  • 1
    needed to "su -" and use "export" as root. Nov 14, 2010 at 18:20
  • 1
    sudo DEBIAN_FRONTEND=noninteractive apt install -y package_you_want
    – aGuegu
    Mar 4, 2019 at 23:25
7

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
0

This should work:

$ pkgadd SOMEpkg << MYINPUT

y

some text

/usr/local

n

password

MYINPUT

I had to place blnk lines between the lines above or it formatted as one long line. In any case you can use the "script" command to save your input during complex installs, and then modify the output into a script to automate it for subsequent installations (man script).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .