0

I am configuring a server connected to an UPS. The UPS is managed via apcupsd and it calls some scripts when there is a power outage and when the situation goes back to normal.

The server is running serveral virtual machines that are launched by the user vboxuser. I'd like to gracefully stop the virtual machines when there is a power outage and I can do that running vboxmanage.

How can I run the command as vboxuser from the scripts called by apcupsd?

1

If the apcupsd scripts run as root then you should be able to just run the shutdown commands in the script using sudo:

/path/to/sudo -u vboxuser /path/to/shutdown-command args

(i.e., create a shell script which gets run by the apc daemon, and put all the sudo shutdown commands into it)

If the scripts don't run as root then you still may be able to use sudo, by configuring it to allow the relevant user the run the shutdown commands as vboxuser. If that's the case you may have to look into the sudo man pages, or wait for a more detailed answer that covers it as I'm in no way an expert on sudo.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.