Solved

Script to shutdown Linux MA services gracefully

  • 9 December 2021
  • 3 replies
  • 257 views

Badge +4

Hi all. Has anyone developed a shell script to place a Media Agent into maintenance mode and stop services? I’m trying to cobble something together without hard coding credentials when running qlogin at the beginning of the script.

I essentially need to run:

./qoperation execscript -sn setMediaAgentProperty -si mediagent -si 8 -si 1

commvault stop

 

 

icon

Best answer by Scott Moseman 10 December 2021, 03:18

View original

3 replies

Userlevel 6
Badge +17

Are you concerned about the password because you want to create a script that multiple users can execute but you don’t want them to see the password?  We can resolve this using sudo.

Create the scripts, chmod 700 the scripts, and config /etc/sudoers so users can run them.

Here’s an example I created of a script that runs “commvault status”.  My user cannot access the script to see what’s inside, but my user can run the script.  Does this address your concerns?

$ cat /root/status.sh
cat: /root/status.sh: Permission denied

$ sudo /root/status.sh | grep Version
 Version = 11.25.9

Thanks,
Scott
 

Userlevel 3
Badge +4

You can generate an encrypted token file and use that to authenticate for each command

https://documentation.commvault.com/11.24/expert/45203_qlogin.html#qlogin-using-token

 

Badge +4

Are you concerned about the password because you want to create a script that multiple users can execute but you don’t want them to see the password?  We can resolve this using sudo.

Create the scripts, chmod 700 the scripts, and config /etc/sudoers so users can run them.

Here’s an example I created of a script that runs “commvault status”.  My user cannot access the script to see what’s inside, but my user can run the script.  Does this address your concerns?

$ cat /root/status.sh
cat: /root/status.sh: Permission denied

$ sudo /root/status.sh | grep Version
 Version = 11.25.9

Thanks,
Scott
 

Yes! Sorry for the late reply. We’re going to test this out in our lab and I’ll report back.

Reply