Shell Script – How to Skip Prompt When Installing Samba

aptraspberry pisambashell-scriptsoftware installation

I would like to create a script to install everything on my raspberry pi (after reinstallation or on another pi, but this is linux question in general). I write down the commands one by one into my script, but when I install samba sudo apt-get install samba -y the following question opens and awaits an answer:

Samba server and utilities

If your computer gets IP address information from a DHCP server on the network,
the DHCP server may also provide information about WINS servers
("NetBIOS name servers") present on the network.
This requires a change to your smb.conf file so that DHCP-provided WINS settings
will automatically be read from /var/lib/samba/dhcp.conf.

The dhcp-client package must be installed to take advantage of this feature.
Modify smb.conf to use WINS settings from DHCP?

<Yes>   <No>

How can I skip this question? I would like the installation to proceed automatically, but this question is waiting for an user input. Is there any other parameter to avoid this question or set answer before run installation?

Best Answer

I found the answer (for apt-get not in general for samba install) in this thread to apt-get.

The debconf-set-selections command helped me set answer before installation start.
If you want to answer "yes", you can use the following commands:

echo "samba-common samba-common/workgroup string  WORKGROUP" | sudo debconf-set-selections
echo "samba-common samba-common/dhcp boolean true" | sudo debconf-set-selections
echo "samba-common samba-common/do_debconf boolean true" | sudo debconf-set-selections
sudo apt-get install samba -y
Related Question