bash 脚本编程十五 MySQL自动部署
现在来考虑MySQL在Ubuntu上的自动部署,有几个问题需要解决:
第一,检查是否安装过了MySQL
第二,安装过程中避免交互式输入root密码
在tool.sh中添加函数检查dpkg包。
#!/bin/bash source ../common/tool.shmysql="mysql-server-5.5"hasDpkg $mysqlr=$?#!/bin/bash if [ $r -eq 1 ]then echo "$mysql was installed"else echo "$mysql was not installed" echo mysql-server mysql-server/root_password password 1234 | sudo debconf-set-selections echo mysql-server mysql-server/root_password_again password 1234 | sudo debconf-set-selections apt-get install $mysqlfi