Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
864 views
in Technique[技术] by (71.8m points)

ubuntu - How can I automate dpkg/apt-get?

I'm trying to create a script that automatically downloads packages for new servers. However, some things like 'mysql-server' can not installed automatically cause you need to configure them in the ncurses interface first. I've looked through the man pages and can't find anything appropriate.

I don't care if I have to upload/edit a conf file later -- I just need the appropriate packages installed.

Anyone know what to do besides grabbing tarballs and building them myself?

UPDATE found out that for things like mysql-server you can just do:

DEBIAN_FRONTEND='noninteractive' apt-get install -yq mysql-server

however expect looks like something I'll need for sun-java6-jdk; haven't evaluated it yet

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Answer from ossramblings.com:

First, install your package normally; then, extract the configuration answers from the debconf data files:

sudo apt-get install debconf-utils
sudo debconf-get-selections | grep mypackage > something.seed

Then, for other installations, you can apply it before installing the package:

sudo debconf-set-selections ./something.seed

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...