YEEEESSS!!! THIS!!! Thank you! I’ve been able to hobble together a script now that I have a Synology automated task calling early each morning after world backups are complete. I’m so very grateful to you all. I’ve learned a lot. A proper “stop” is being issues now which reduces the chance of world corruption which would make my family very very grumpy.
Here’s the script just in case someone finds themselves in a similar situation as me. This is not my wheelhouse and it’s not pretty. I know it can be better, but I’ve spent too much time on this as it is and need to go fix a washing machine now. Ugh…
#!/bin/bash
# Define the countdown duration in seconds
countdown_duration=20
# Function to send a message to the Docker container
send_cmd() {
cmd="$1"
sudo sh -c "echo '$cmd' | socat EXEC:'docker attach mcbe-world',pty STDIN"
}
# Announce
announce_text="Daily server restart commencing in $countdown_duration seconds..."
send_cmd "say $announce_text"
# Perform the countdown
for ((i = $countdown_duration; i >= 1; i--)); do
#echo "Restaring in $i seconds"
countdown_text="Restarting in $i seconds"
send_cmd "say $countdown_text"
sleep 1
done
# Gracefully shutdown server
# Note: stopping forces the mcbe container to restart on it's own.
# Not sure why that's the case, but it's the end result I want...
send_cmd "stop"
P.S. I really need to figure out how to get the RCON solution working because that would be a more elegant way to handle things.
P.P.S Example run (yes, the timing and spelling were updated after this screenshot 😁)
Good to know about the main proc. I wasn’t aware. And it is indeed set to auto restart. I just hadn’t realized the stop alone would trigger that. I had figured I would need to take the additional step.