#!/bin/sh
screen -x mc
screen -s mc -X stuff "say Server Restarting in §f30§8 minutes."
screen -s mc -X eval "stuff \015"
sleep 900
screen -x mc
screen -s mc -X stuff "say Server Restarting in §e15§8 minutes."
screen -s mc -X eval "stuff \015"
sleep 600
screen -x mc
screen -s mc -X stuff "say Server Restarting in §c5§8 minutes."
screen -s mc -X eval "stuff \015"
sleep 240
screen -x mc
screen -s mc -X stuff "say Server Restarting in §41§8 minute."
screen -s mc -X eval "stuff \015"
sleep 60
screen -S mc -X stuff "say Server is restarting"
screen -S mc -X eval "stuff \015"
screen -S mc -X stuff "kickall Server is restarting"
screen -S mc -X eval "stuff \015"
sleep 2
screen -S mc -X stuff "stop"
screen -S mc -X eval "stuff \015"
sleep 45
screen -wipe
pkill start.sh
sleep 5
cd /Minecraft
./start.sh
I used crontab to make restart.sh start daily at a specific time, however it does not seem to get the first message sent (unless I end it). Any ideas?
I use screen -x instead of screen -s when scripting console commands. This runs it in multi-display mode, allowing 2 users to send commands to same session.
example:
if ps ax | grep -v grep | grep -v -i SCREEN | grep $SERVICE > /dev/null
then
as_user "screen -x -X eval 'stuff \"save-off\"\015'"
sleep 2
echo "saveoff: forcing changes to disk"
as_user "screen -x -X eval 'stuff \"save-all\"\015'"
sync
sleep 10
else
echo "saveoff: $SERVICE was not running. Not suspending saves."
fi
I highly recommend looking up and trying out the Minecraft remote toolkit, which has quite a few features (including telnet, scheduled restarts, scheduled saves, auto-restart-on-severe-exceptions, and more.
“Two things are infinite: the universe and human stupidity; and I'm not sure about the universe.” — Albert Einstein
"Never try to teach a pig to sing; it wastes your time and it annoys the pig." — Robert Heinlein
I think it is pretty cool that she's working out her own solution. Installing someone else's server wrapper wrapper isn't really going to help her fix her problem.
start.sh
And restart.sh
I used crontab to make restart.sh start daily at a specific time, however it does not seem to get the first message sent (unless I end it). Any ideas?
Now that the restart is capable of starting it, I still have issues sending the messages.
However this may be because I am in console, testing now.
example:
"Never try to teach a pig to sing; it wastes your time and it annoys the pig." — Robert Heinlein
The way my script works, it needs to exit the server screen before it is released, therefore I need to have user input "control+a, d"