在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

如果您觉得本文章受用,请点个赞,给个评论!谢谢.~~~

最新文章

  1. android自定义控件(8)-利用onMeasure测量使图片拉伸永不变形,解决屏幕适配问题
  2. Python之函数进阶
  3. poll()
  4. 转自 z55250825 的几篇关于FFT的博文(二)
  5. Train Problem I
  6. Delphi在StatusBar上绘制ProgressBar
  7. 关于WIN7 家庭版 iis 部署问题
  8. Blocks [POJ3734] [矩阵快速幂]
  9. 解读《德勤2017年全球CIO报告》:顶级CIO的炼成之道
  10. HDU - 1695 GDU
  11. JMeter进行一次简单的压力测试
  12. 解决tomcat启动慢问题
  13. Codeforces 866C Gotta Go Fast - 动态规划 - 概率与期望 - 二分答案
  14. HDU4267 树状数组
  15. Unity ZTest深度测试 &amp; ZWrite深度写入
  16. 更换php工具箱出现问题 CI框架的问题 【问题解决】
  17. 使用libsvm对MNIST数据集进行实验---浅显易懂!
  18. 【树链剖分】bzoj2243 [SDOI2011]染色
  19. 巨蟒python全栈开发数据库前端5:JavaScript1
  20. Application received signal SIGABRT

热门文章

  1. linux系统引导过程
  2. Mybatis + js 实现下拉列表二级联动
  3. EMS邮箱数据库全局监控设置
  4. JavaScript中数组的方法和字符串方法总结
  5. Docker 核心知识回顾
  6. Factorials and Powers of Two
  7. cali1e4a9cee8dc这是什么东西?
  8. 在非k8s 环境下 的应用 使用 Dapr Sidekick for .NET
  9. 怎么快速找出帝国CMS数据库配置文件路径及迁移网站后修改技巧!
  10. 共读《redis设计与实现》-数据结构篇