Ubuntu 静默安装DEB包(非交互式)~解决Ubuntu下安装DEB包弹窗交互的问题
2024-10-13 23:05:48
在Ubuntu环境下安装DEB包时,比如安装MySQL式经常会弹出交互式要输入密码的操作。有时候我们期望编写Shell脚本一键部署MySQL时不想要弹窗交互时,则可以使用以下方式实现自动化安装Deb软件。
概述
debconf-utils是一个可以在Ubuntu下预先配置要安装程序的小工具,它可以避免在安装一个DEB程序时的弹窗输入问题,这可能在编写一键部署脚本的时候非常有用。
以下我们用安装MySQL-APT源作为示例。
1、安装debconf-utils
root@ubuntu:~# apt-get -y install debconf-utils
2、更新APT源
root@ubuntu:~# apt-get update
3、先手动安装一遍MySQL-APT源
此时有弹窗!根据弹窗和自己的需求输入并安装一遍。
root@ubuntu:~# wget https://repo.mysql.com/mysql-apt-config_0.8.13-1_all.deb
root@ubuntu:~# dpkg -i mysql-apt-config_0.8.13-1_all.deb
4、查询想要预先配置的DEB程序的相关配置信息
通过已安装的DEB程序,获取到想要静默安装预配置信息。
root@ubuntu:~# debconf-get-selections |grep 'mysql-apt-config'
mysql-apt-config mysql-apt-config/select-tools select Enabled
mysql-apt-config mysql-apt-config/select-server select mysql-5.7
mysql-apt-config mysql-apt-config/repo-url string http://repo.mysql.com/apt
mysql-apt-config mysql-apt-config/preview-component string
mysql-apt-config mysql-apt-config/repo-codename select xenial
mysql-apt-config mysql-apt-config/tools-component string mysql-tools
mysql-apt-config mysql-apt-config/select-preview select Disabled
mysql-apt-config mysql-apt-config/select-product select Ok
mysql-apt-config mysql-apt-config/repo-distro select ubuntu
mysql-apt-config mysql-apt-config/unsupported-platform select abort
mysql-apt-config mysql-apt-config/dmr-warning note
5、然后卸载已安装的DEB包
卸载刚刚需要通过图形化弹窗安装程序。
root@ubuntu:~# apt-get -y remove mysql-apt-config
6、重新安装DEB包,预配置软件
根据上面获取到预配置信息,预配置软件。
root@ubuntu:~# debconf-set-selections << EOF
mysql-apt-config mysql-apt-config/select-tools select Enabled
mysql-apt-config mysql-apt-config/select-server select mysql-5.7
mysql-apt-config mysql-apt-config/repo-url string http://repo.mysql.com/apt
mysql-apt-config mysql-apt-config/preview-component string
mysql-apt-config mysql-apt-config/repo-codename select xenial
mysql-apt-config mysql-apt-config/tools-component string mysql-tools
mysql-apt-config mysql-apt-config/select-preview select Disabled
mysql-apt-config mysql-apt-config/select-product select Ok
mysql-apt-config mysql-apt-config/repo-distro select ubuntu
mysql-apt-config mysql-apt-config/unsupported-platform select abort
mysql-apt-config mysql-apt-config/dmr-warning note
EOF
6、关闭交互式的静默安装DEB包
你会发现没有弹窗提示了!
root@ubuntu:~# DEBIAN_FRONTEND=noninteractive apt-get -y install ./mysql-apt-config_0.8.13-1_all.deb
如果您觉得本文章受用,请点个赞,给个评论!谢谢.~~~
最新文章
- android自定义控件(8)-利用onMeasure测量使图片拉伸永不变形,解决屏幕适配问题
- Python之函数进阶
- poll()
- 转自 z55250825 的几篇关于FFT的博文(二)
- Train Problem I
- Delphi在StatusBar上绘制ProgressBar
- 关于WIN7 家庭版 iis 部署问题
- Blocks [POJ3734] [矩阵快速幂]
- 解读《德勤2017年全球CIO报告》:顶级CIO的炼成之道
- HDU - 1695 GDU
- JMeter进行一次简单的压力测试
- 解决tomcat启动慢问题
- Codeforces 866C Gotta Go Fast - 动态规划 - 概率与期望 - 二分答案
- HDU4267 树状数组
- Unity ZTest深度测试 &; ZWrite深度写入
- 更换php工具箱出现问题 CI框架的问题 【问题解决】
- 使用libsvm对MNIST数据集进行实验---浅显易懂!
- 【树链剖分】bzoj2243 [SDOI2011]染色
- 巨蟒python全栈开发数据库前端5:JavaScript1
- Application received signal SIGABRT