I'm currently creating a build agent for our DevOps. With the agent I want to stop solr via shell script on the unix server. The problem is, I need to insert a password, to stop the service.
Is there a simple way to provide the password in the shell script? The current script:
service solr stop
throws the following error:
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
I also tried to provide the password on the script, like:
echo <password> | sudo -S service solr stop
It works on the server locally, but the buildserver throws:
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
Any other ideas how I could remotely stop solr with a shell script?