我正在运行一个带有Fabric的Python脚本,该脚本远程发送bash脚本并执行。脚本必须自动在多个远程服务器上运行(没有用户的干扰)。
但是,当我安装这2包时,命令行中的GUI界面提示符就有点复杂了。这将导致bash脚本“挂起”,等待用户输入继续。
在命令行中没有GUI界面提示符的情况下,是否有配置流程的替代方法?
发布于 2011-11-18 21:53:29
在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)
https://stackoverflow.com/questions/8170691
复制