문제

I would like to write the following Bash Script:

When installing LAMP like this, it would ask me a root password for the MySQL installation. I would like to bash script it.

sudo apt-get install lamp-server^

Can I do it like this to pass the variable as a parameter so it would not ask me about it during installation?

rootPassword="MyRootPassword";

sudo apt-get install lamp-server^ -y $rootPassword
도움이 되었습니까?

해결책

In order to answer debconf questions non-interactively, you will need the debconf-utils package. The debconf-set-selections command can be used to manually insert things into the debconf database that will normally be asked interactively. This can also be done at OS install time using FAI or preseeding.

export DEBIAN_FRONTEND=noninteractive
debconf-set-selections < 'mysql-server-5.1 mysql-server/root_password select PASSWORD'
debconf-set-selections < 'mysql-server-5.1 mysql-server/root_password_again select PASSWORD'

You will likely need to change the name of the mysql-server package name to the version used by your distribution. Note that the package "mysql" is a virtual package which points to the real package (which includes the version number).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top