有时候我们在初始化环境的时候并不希望软件有交互式安装,而是直接走默认,比如clickhouse
要想关闭交互式安装目前我知道的有三种方式(不过前两种在Ubuntu 22.04上并不好使)
# 这种方式在Ubuntu 22.04上貌似不好使
echo -e "\n" | sudo dpkg -i clickhouse-server*
# 这种也不行
sudo dpkg -i clickhouse-server* < /dev/null
# 这种看着很专业,但是测得时候是生效的,当我准备发版的时候发现又不好使了
cat <<EOF > configfile
clickhouse-server clickhouse-server/user seen true
clickhouse-server clickhouse-server/user string your_username
clickhouse-server clickhouse-server/password-crypted password your_password
EOF
sudo debconf-set-selections < configfile
sudo apt-get install clickhouse-server
# 只有这种比较亲民,简单好用
DEBIAN_FRONTEND=noninteractive dpkg -i clickhouse-server*