From 3a282512623f0a116a0282c35314747a36e6ac4c Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Wed, 6 May 2020 12:20:39 -0300 Subject: [PATCH] Including some dummy and messy scripts to Minecraft Just a service to inform time and closer Minecraft servers after some time, so kids are not going to sleep so late. --- Services/minecraft-hour.service | 6 ++++++ Services/minecraft-hour.sh | 23 +++++++++++++++++++++++ Services/minecraft-hour.timer | 12 ++++++++++++ 3 files changed, 41 insertions(+) create mode 100755 Services/minecraft-hour.service create mode 100755 Services/minecraft-hour.sh create mode 100755 Services/minecraft-hour.timer diff --git a/Services/minecraft-hour.service b/Services/minecraft-hour.service new file mode 100755 index 0000000..62f5a8b --- /dev/null +++ b/Services/minecraft-hour.service @@ -0,0 +1,6 @@ +[Unit] +Description=Minecraft Informa a Hora Certa + +[Service] +User=bruno +ExecStart=/bin/sh /home/bruno/Apps/linuxShortcuts/Services/minecraft-hour.sh diff --git a/Services/minecraft-hour.sh b/Services/minecraft-hour.sh new file mode 100755 index 0000000..6c208b1 --- /dev/null +++ b/Services/minecraft-hour.sh @@ -0,0 +1,23 @@ +if ! screen -list | grep -q "minecraftPE"; then + exit 1 +fi + +function runAllWorlds () { + screen -S minecraftPESurvival -X stuff "$1" + screen -S minecraftPECreative -X stuff "$1" +} + +runAllWorlds "say $(date +%l:%M)\n" + +HORA=$(date +%H) +if [ "$HORA" -ge 23 ]; then + screen -S minecraftPECreative -X stuff $'say Hora de dormir\n' + sleep 5 + screen -S minecraftPECreative -X stuff $'stop\n' + + if [ "$HORA" -ge 1 -a "$HORA" -lt 5 ]; then + screen -S minecraftPESurvival -X stuff $'say Hora de dormir\n' + source /home/bruno/Apps/Minecraft/stopServers.sh + fi + +fi diff --git a/Services/minecraft-hour.timer b/Services/minecraft-hour.timer new file mode 100755 index 0000000..8846602 --- /dev/null +++ b/Services/minecraft-hour.timer @@ -0,0 +1,12 @@ +[Unit] +Description=Minecraft Informa a Hora Certa +Requires=minecraft-hour.service + +[Timer] +Unit=minecraft-hour.service +OnCalendar=*-*-* *:0,15,30,45:00 +#DayOfWeek Year-Month-Day Hour:Minute:Second +AccuracySec=1s + +[Install] +WantedBy=timers.target