1. 用debconf-show + 包名查出预配置项。
2. 在脚本里,用debconf-set-selections设置然后安装。
在debconf database中插入默认值
/usr/bin/debconf-set-selections
debconf-set-selections [-vcu] [file]
1
2
3
|
-
v
,
--
verbose
显示运行过程信息
-
c
,
--
checkonly
只检查输入文件的格式
-
u
,
--
unseen
在预置参数时,不设置
'seen'标识
|
1、命令行输入设置参数
sudo debconf-set-selections <<< 'mysql-server-5.5 mysql-server/root_password password your_password'
sudo debconf-set-selections <<< 'mysql-server-5.5 mysql-server/root_password_again password your_password'
sudo apt-get -y install mysql-server
2、先输入文件,再一次性添入设置参数
echo "mysql-server-5.5 mysql-server/root_password password $MYSQL_ROOT_PASS" > /tmp/mysql.preseed
echo "mysql-server-5.5 mysql-server/root_password_again password $MYSQL_ROOT_PASS" >> /tmp/mysql.preseed
cat /tmp/mysql.preseed | sudo debconf-set-selections
rm /tmp/mysql.preseed
sudo apt-get install -y mysql-server
3、使用echo方式输入设置参数
echo 'mysql-server-5.5 mysql-server/root_password password your_password' | sudo debconf-set-selections
echo 'mysql-server-5.5 mysql-server/root_password_again password your_password' | sudo debconf-set-selections
sudo apt-get install -y mysql-server
4、直接从文件中读取设置参数
sudo debconf-set-selections mysql-passwd
sudo apt-get install -y mysql-server