2

I would like to create a bash file to automate a docker installation with following commands:

sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-keys <key>
echo "deb https://apt.dockerproject.org/repo ubuntu-xenial main" | sudo tee /etc/apt/sources.list.d/docker.list
sudo apt-get update
apt-cache policy docker-engine
sudo apt-get install linux-image-extra-$(uname -r) linux-image-extra-virtual
sudo apt-get install docker-engine
sudo service docker start

For me it is new, so I need a little advice. How can I handle commands which asks for confirmations?

Can I summarize both apt-get install lines?

closed as unclear what you're asking by mdpc, G-Man, countermode, user34720, Archemar Jan 18 '17 at 12:12

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • If you're going to automate the process you need to identify which commands might ask for confirmation. Then you can check the man page for those commands to see if there's any way you can provide an answer (maybe a flag, or maybe it defaults to one particular course of action if there's no stdin to read an answer from). – roaima Jan 18 '17 at 9:00
1

apt-get takes -y (--yes/--assume-yes) option to take yes as the value for confirmation on such prompts, it's like pressing Y interactively.

So you can do:

apt-get install -y ...

Not the answer you're looking for? Browse other questions tagged or ask your own question.