Skip to main content
Solved

Script to shutdown Linux MA services gracefully

  • December 9, 2021
  • 3 replies
  • 292 views

Frank Grimes
Byte
Forum|alt.badge.img+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

 

 

Best answer by Scott Moseman

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
 

View original

3 replies

Scott Moseman
Vaulter
Forum|alt.badge.img+18
  • Vaulter
  • 512 replies
  • Answer
  • December 10, 2021

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
 


Forum|alt.badge.img+6
  • Vaulter
  • 26 replies
  • December 10, 2021

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

 


Frank Grimes
Byte
Forum|alt.badge.img+4
  • Author
  • Byte
  • 11 replies
  • January 25, 2022
Scott Moseman wrote:

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings