自动远程安装 mysql-server 和 postfix

发布于 2024-12-16 17:27:57 字数 268 浏览 0 评论 0原文

我正在使用 Fabric 运行 Python 脚本,该脚本远程发送 bash 脚本并执行。 该脚本必须自动在多个远程服务器上运行(无需用户干预)。

但是当我安装这两个包时,命令行中的 GUI 界面提示有点复杂。这会导致 bash 脚本“挂起”,等待用户输入继续。

  1. mysql-server (提示用户输入 root 密码)
  2. postfix (提示某些配置设置)

是否有其他方法可以在命令行中不使用 GUI 界面提示来配置进程?

I am running a Python script with Fabric which sent a bash script over remotely and execute.
The script will have to run over multiple remote servers automatically (without user interference).

But when I am installing these 2 package, there is a small complication of GUI interface prompt in the command line. This cause the bash script to 'hang', awaiting for user input to continue.

  1. mysql-server (Prompting user for root password)
  2. postfix (Prompting for some configuration setting)

Is there an alternative to configure the process without the GUI interface prompt in the command line?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风铃鹿 2024-12-23 17:27:57

http://www.muhuk.com/2010 /05/how-to-install-mysql-with-fabric/ 它描述了安装 mysql-server 的解决方案,基本上你要做的是:

# password prompt 
while True:
    mysql_password = getpass('Please enter MySQL root password: ')
    mysql_password_confirmation = getpass('Please confirm your password: ')
    if mysql_password == mysql_password_confirmation:
        break
    else:
        print "Passwords don't match"

# set the value in debconf
with settings(hide('warnings', 'running', 'stdout', 'stderr'),
              warn_only=True):
    if not run('dpkg-query --show mysql-server'):
        sudo('echo "mysql-server-5.1 mysql-server/root_password password '
            '%s" | debconf-set-selections' % mysql_password)
        sudo('echo "mysql-server-5.1 mysql-server/root_password_again '
             'password %s" | debconf-set-selections' % mysql_password)

In http://www.muhuk.com/2010/05/how-to-install-mysql-with-fabric/ it's described a solution to the installation of mysql-server, basically what you have to do is:

# password prompt 
while True:
    mysql_password = getpass('Please enter MySQL root password: ')
    mysql_password_confirmation = getpass('Please confirm your password: ')
    if mysql_password == mysql_password_confirmation:
        break
    else:
        print "Passwords don't match"

# set the value in debconf
with settings(hide('warnings', 'running', 'stdout', 'stderr'),
              warn_only=True):
    if not run('dpkg-query --show mysql-server'):
        sudo('echo "mysql-server-5.1 mysql-server/root_password password '
            '%s" | debconf-set-selections' % mysql_password)
        sudo('echo "mysql-server-5.1 mysql-server/root_password_again '
             'password %s" | debconf-set-selections' % mysql_password)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文