MineOS with UPS & apcupsd

I am running MineOS on Ubuntu and have questions about running it alongside apcupsd.

I am using apcupsd to monitor the battery backup and to trigger a clean shutdown. Does Mineos offer any support for this? If the apcupsd service triggers a shutdown will MineOS close cleanly? Is there anything I need to do to make sure that happens?

Thanks

MineOS, the webui, can be killed abruptly, and there are no issues that should arise from repeated forced shutdowns. Depending on which method MineOS is installed with (systemd, for example), the webui can also be closed gracefully when the system attempts to shut down.

That said, Minecraft itself is not as forgiving, and forced shutdowns can corrupt worlds or fail to commit to disk recent world changes.

Due to the nature of MineOS+Minecraft, these two are left unconnected. Restarting MineOS is necessary when a) MineOS scripts are updated or b) MineOS crashes–neither of these behaviors should warrant closing down Minecraft servers themselves.

As such, as long as your Minecraft servers are shut down cleanly, you should be good. I’m not familiar with apcupsd, but if it allows you to execute arbitrary commands, you can definitely allow it do to:

cd /usr/games/minecraft && ./mineos_console.js -s SERVERNAME stop

Presumably, one line for each of your servers you need to have shut down.

Thanks!

apcupsd does allow for command execution before shutdown. For anyone in the future who also needs this I added the following text into the file /etc/apcupsd/doshutdown

#!/bin/sh
cd /usr/games/minecraft && ./mineos_console.js -s SERVERNAME stop
sleep 60
exit 0 #exiting with 0 continues with standard shutdown.

Is there any way to also broadcast a message on the server from a shell script? By invoking the say command for instance?

cd /usr/games/minecraft && ./mineos_console.js -s SERVERNAME stuff say hello

stuff is the command used for the screen program, so it does belong there as written.

That didn’t work for me at first, the stop command didn’t either then I realized I has to run the command as the user that created the server.

sudo runuser -l USER -c 'cd /usr/games/minecraft && .mineos_console.js -s SERVERNAME stop'

Using runuser under root worked great.

Thanks!

1 Like