我目前正在为我们的DevOps创建一个构建代理。对于代理,我想通过UNIX服务器上的shell脚本停止solr。问题是,我需要输入密码才能停止服务。
是否有一种简单的方法可以在shell脚本中提供密码?当前脚本:
service solr stop
引发以下错误:
2020-03-12T12:50:27.0480993Z Successfully connected.
2020-03-12T12:50:27.0483958Z service solr stop
2020-03-12T12:50:29.7903365Z
2020-03-12T12:50:29.8193011Z ##[error]Failed to stop solr.service: Interactive authentication required.
2020-03-12T12:50:29.8208401Z
2020-03-12T12:50:29.8208979Z
2020-03-12T12:50:29.8209589Z ##[error]See system logs and 'systemctl status solr.service' for details.
2020-03-12T12:50:29.8209971Z
2020-03-12T12:50:29.8210587Z ##[error]Command failed with errors on remote machine.
2020-03-12T12:50:29.8341862Z ##[section]Finishing: stop solr
我也试图在脚本上提供密码,例如:
echo <password> | sudo -S service solr stop
它在本地服务器上工作,但是buildserver抛出:
2020-03-12T12:52:17.9543478Z Successfully connected.
2020-03-12T12:52:17.9545108Z echo *** | sudo -S service solr stop
2020-03-12T12:52:18.9946984Z ##[error][sudo] password for ***:
2020-03-12T12:52:23.4808034Z ##[error]Command failed with errors on remote machine.
2020-03-12T12:52:23.5019910Z ##[section]Finishing: stop solr
还有其他想法,我如何可以使用shell脚本远程停止solr?
如上所述,我找到了一个解决方案,并将其发布在另一篇文章中。这是答案链接:https://stackoverflow.com/a/60666738/5835745