How to use debcondf Show results with debconf-set-selections?

I'd like to know in common how to use the results of debconf-show with debconf set selections to precvonfigure deb packages with the command line or within a shell script

For example

If I use

sudo debconf-get-selections | grep java7 > result;cat result

I get the following

oracle-java7-installer  shared/present-oracle-license-v1-1  note    
oracle-java7-installer  oracle-java7-installer/local    string  
oracle-java7-installer  shared/accepted-oracle-license-v1-1 boolean true
oracle-java7-installer  shared/error-oracle-license-v1-1    error   
oracle-java7-installer  oracle-java7-installer/not_exist    error

How would the right debconf set selections line look like to configure the two dialoges that appear trough the installation?

In general how is the right syntax of debconf set selections I assume there are not only booleans like true or false and yes or no

I guess there is much more an other example will be how to select the default desktop manager if lightdm and gdm installed by a bash script.

Is there a general proofed approach to determine and the right values for a debconf package and write a proper bash script that installs something like the webupt8 java package and preselect the values that the user normally would be asked for?


Solution 1:

You need to use pre-seeding. The debconf-set-selections command presets answers asked by debconf before installing the package.

E.G.

sudo debconf-set-selections <<< "shared/accepted-oracle-license-v1-1 boolean true"

Then install the package.

sudo apt-get install -y oracle-java7-installer