#!/bin/bash##############################################################Minecraftserverautoupdatetool!#THISMUSTBERUNASROOTinROOTSCRONTAB##CrontabinfoforweeklychecksonWed3AM.#03**3/opt/minecraft/update_mc.sh#-Corry#############################################################CPath=/opt/minecraftJAVA="False"Current_Version=`ls${CPath}/server|grepminecraft_server`printf"This script to to see if there is a newer version of MineCraft!!\n\nChecking to see what version is available from Minecraft website\n"MC_Version=`curl-A"Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/81.0"https://www.minecraft.net/en-us/download/server|grep"minecraft_server"|awk-F'>''{print $NF}'|column-t`if["${MC_Version}"!="${Current_Version}"]thenprintf"Newer Version found...\nThe process will take roughly less than 2 of your earth minutes\nShutting down Minecraft\nChecking Java version... "date+'[%H:%M:%S] [Server thread/INFO]: <System Message> Newer Version found... The process will take roughly less than 2 of your earth minutes. Shutting down Minecraft.'>>${CPATH}/server/logs/latest.logsleep10systemctlstopminecraftprintf"Newer Version found...\nChecking Java... "#updateOpenJDKCurrentJDK=`aptlist|grep^openjdk|cut-d--f-2|sort-u-V|tail-1`LatestJDK=`apt-cachesearchopenjdk|grep^openjdk|cut-d--f-2|sort-u-V|tail-1`if["${LatestJDK}"!="${CurrentJDK}"]thenif["$JAVA"=="True"]thenapt-get-yinstall${LatestJDK}-jre${LatestJDK}-jdkelseprintf"Java update skipped"fifi#updateMinecraftrm${CPath}/server/${Current_Version}${CPath}/server/server.jarMCVersion=`curl-A"Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/81.0"https://www.minecraft.net/en-us/download/server|grep'server.jar'|cut-d\" -f2`aptupdate#downloadlatestserverfromherewget$MCVersion-P${CPath}/serversleep30chownminecraft:minecraft${CPath}/serverln-s${CPath}/server/server.jar${CPath}/server/${MC_Version}printf"Starting MineCraft updated version $MC_Version\n"systemctlstartminecrafteula=`tail-1${CPath}/server/eula.txt|cut-d=-f2`if["${eula}"=="false"]thenprintf"accepting EULA\n"sleep10systemctlstopminecraftsed-i's/false/TRUE/g'${CPath}/server/eula.txtsleep10systemctlstartminecraftfielseprintf"On Current Version!\n No changes to be Made...\n"fiprintf"\nExiting\n"