diff --git a/FistfulOfFrags/cfg/lgsm-default.cfg b/FistfulOfFrags/cfg/lgsm-default.cfg index 615720feb..39783e9d8 100644 --- a/FistfulOfFrags/cfg/lgsm-default.cfg +++ b/FistfulOfFrags/cfg/lgsm-default.cfg @@ -1,7 +1,7 @@ // **************************************************************************** // * // Fistful of Frags - server.cfg * -// Version 100116 * +// Version 240716 * // * // **************************************************************************** @@ -25,7 +25,7 @@ sv_lan 0 // ............................... Map Cycles ............................... // // info: There are several predefined mapcycles available that are listed below. -// You can also create your own custom mapcycle. +// You can also create your own custom mapcycle. // "mapcycle.txt" - All Shootout/2 Team Shootout/4 Team Shootout maps // "mapcycle_12.txt" - All 12 slot maps for Shootout/2 Team Shootout/4 Team Shootout @@ -50,7 +50,7 @@ mp_timelimit 15 // 3 = Break Bad // 4 = Elimination // 5 = Versus -fof_sv_currentmode 1 +fof_sv_currentmode 1 // Teamplay // 0 = Free-for-all @@ -98,7 +98,7 @@ sv_downloadurl "" // personal banlist based on user IDs. exec banned_user.cfg -// personal banlist based on user IPs. +// personal banlist based on user IPs. exec banned_ip.cfg writeid diff --git a/Minecraft/cfg/lgsm-default.ini b/Minecraft/cfg/lgsm-default.ini new file mode 100644 index 000000000..8e350192c --- /dev/null +++ b/Minecraft/cfg/lgsm-default.ini @@ -0,0 +1,40 @@ +#Minecraft server properties (LGSM 210516) +#Sat Aug 20 17:30:15 CEST 2016 +allow-flight=false +allow-nether=true +announce-player-achievements=true +difficulty=1 +enable-command-block=false +enable-query=false +enable-rcon=false +force-gamemode=false +gamemode=0 +generate-structures=true +generator-settings= +hardcore=false +level-name=world +level-seed= +level-type=DEFAULT +max-build-height=256 +max-players=20 +max-tick-time=60000 +max-world-size=29999984 +motd=A Minecraft Server +network-compression-threshold=256 +online-mode=true +op-permission-level=4 +player-idle-timeout=0 +pvp=true +rcon.password= +rcon.port=25575 +resource-pack-sha1= +resource-pack= +server-ip= +server-port=25565 +snooper-enabled=true +spawn-animals=true +spawn-monsters=true +spawn-npcs=true +use-native-transport=true +view-distance=10 +white-list=false diff --git a/Minecraft/mcserver b/Minecraft/mcserver new file mode 100644 index 000000000..e9bb190fe --- /dev/null +++ b/Minecraft/mcserver @@ -0,0 +1,142 @@ +#!/bin/bash +# Minecraft +# Server Management Script +# Author: Daniel Gibbs +# Website: https://gameservermanagers.com +if [ -f ".dev-debug" ]; then + exec 5>dev-debug.log + BASH_XTRACEFD="5" + set -x +fi + +version="210816" + +#### Variables #### + +# Notification Alerts +# (on|off) + +# Email +emailalert="off" +email="email@example.com" + +# Pushbullet +# https://www.pushbullet.com/#settings +pushbulletalert="off" +pushbullettoken="accesstoken" + +# Start Variables +updateonstart="off" +javaram="1024" # -Xmx$1024M + +fn_parms(){ +parms="nogui" +} + +#### Advanced Variables #### + +# Github Branch Select +# Allows for the use of different function files +# from a different repo and/or branch. +githubuser="GameServerManagers" +githubrepo="LinuxGSM" +githubbranch="master" + +# Server Details +servicename="mc-server" +gamename="Minecraft" +engine="lwjgl2" + +# Directories +rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))" +selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +lockselfname=".${servicename}.lock" +lgsmdir="${rootdir}/lgsm" +functionsdir="${lgsmdir}/functions" +filesdir="${rootdir}/serverfiles" +systemdir="${filesdir}" +executabledir="${filesdir}" +executable="java -Xmx${javaram}M -jar minecraft_server.jar" +servercfg="server.properties" +servercfgdir="${filesdir}" +servercfgfullpath="${servercfgdir}/${servercfg}" +servercfgdefault="${servercfgdir}/lgsm-default.ini" +backupdir="${rootdir}/backups" + +# Logging +logdays="7" +gamelogdir="${systemdir}/logs" +scriptlogdir="${rootdir}/log/script" +consolelogdir="${rootdir}/log/console" +consolelogging="on" + +scriptlog="${scriptlogdir}/${servicename}-script.log" +consolelog="${consolelogdir}/${servicename}-console.log" +emaillog="${scriptlogdir}/${servicename}-email.log" + +scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log" +consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%d-%m-%Y-%H-%M-%S').log" + +##### Script ##### +# Do not edit + +# Fetches core_dl for file downloads +fn_fetch_core_dl(){ +github_file_url_dir="lgsm/functions" +github_file_url_name="${functionfile}" +filedir="${functionsdir}" +filename="${github_file_url_name}" +githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}" +# If the file is missing, then download +if [ ! -f "${filedir}/${filename}" ]; then + if [ ! -d "${filedir}" ]; then + mkdir -p "${filedir}" + fi + echo -e " fetching ${filename}...\c" + # Check curl exists and use available path + curlpaths="$(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl)" + for curlcmd in ${curlpaths} + do + if [ -x "${curlcmd}" ]; then + break + fi + done + # If curl exists download file + if [ "$(basename ${curlcmd})" == "curl" ]; then + curlfetch=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${githuburl}" 2>&1) + if [ $? -ne 0 ]; then + echo -e "\e[0;31mFAIL\e[0m\n" + echo "${curlfetch}" + echo -e "${githuburl}\n" + exit 1 + else + echo -e "\e[0;32mOK\e[0m" + fi + else + echo -e "\e[0;31mFAIL\e[0m\n" + echo "Curl is not installed!" + echo -e "" + exit 1 + fi + chmod +x "${filedir}/${filename}" +fi +source "${filedir}/${filename}" +} + +core_dl.sh(){ +# Functions are defined in core_functions.sh. +functionfile="${FUNCNAME}" +fn_fetch_core_dl +} + +core_functions.sh(){ +# Functions are defined in core_functions.sh. +functionfile="${FUNCNAME}" +fn_fetch_core_dl +} + +core_dl.sh +core_functions.sh + +getopt=$1 +core_getopt.sh diff --git a/lgsm/functions/check_deps.sh b/lgsm/functions/check_deps.sh index ef05af329..1939937ec 100644 --- a/lgsm/functions/check_deps.sh +++ b/lgsm/functions/check_deps.sh @@ -73,7 +73,7 @@ fn_found_missing_deps(){ sleep 1 sudo -v > /dev/null 2>&1 if [ $? -eq 0 ]; then - fn_print_infomation_nl "Automatically installing missing dependencies." + fn_print_information_nl "Automatically installing missing dependencies." fn_script_log_info "Automatically installing missing dependencies." echo -en ".\r" sleep 1 @@ -120,7 +120,7 @@ fn_check_loop(){ fn_deps_detector done - # user to be informaed of any missing dependencies + # user to be informed of any missing dependencies fn_found_missing_deps } @@ -149,8 +149,8 @@ if [ -n "$(command -v dpkg-query)" ]; then fi fi - # All servers except ts3 & mumble require libstdc++6, lib32gcc1 - if [ "${gamename}" != "TeamSpeak 3" ]||[ "${gamename}" != "Mumble" ]; then + # All servers except ts3,mumble and minecraft servers require libstdc++6 and lib32gcc1 + if [ "${gamename}" != "TeamSpeak 3" ]||[ "${gamename}" != "Mumble" ]||[ "${engine}" != "lwjgl2" ]; then if [ "${arch}" == "x86_64" ]; then array_deps_required+=( lib32gcc1 libstdc++6:i386 ) else @@ -179,10 +179,10 @@ if [ -n "$(command -v dpkg-query)" ]; then # Battlefield: 1942 requies ncurses elif [ "${gamename}" == "Battlefield: 1942" ]; then array_deps_required+=( libncurses5:i386 ) - # Project Zomboid - elif [ "${engine}" == "projectzomboid" ]; then + # Project Zomboid and Minecraft + elif [ "${engine}" == "projectzomboid" ]||[ "${engine}" == "lwjgl2" ]; then array_deps_required+=( default-jdk ) - # Unreal engine + # Unreal Engine elif [ "${executable}" == "./ucc-bin" ]; then #UT2K4 if [ -f "${executabledir}/ut2004-bin" ]; then @@ -218,8 +218,8 @@ elif [ -n "$(command -v yum)" ]; then fi fi - # All servers excelts ts3 & mumble require glibc.i686 libstdc++.i686 - if [ "${executable}" != "./ts3server_startscript.sh" ]||[ "${executable}" != "./murmur.x86" ]; then + # All servers except ts3,mumble and minecraft servers require glibc.i686 and libstdc++.i686 + if [ "${gamename}" != "TeamSpeak 3" ]||[ "${gamename}" != "Mumble" ]||[ "${engine}" != "lwjgl2" ]; then array_deps_required+=( glibc.i686 libstdc++.i686 ) fi @@ -237,8 +237,8 @@ elif [ -n "$(command -v yum)" ]; then # Brainbread 2 and Don't Starve Together elif [ "${gamename}" == "Brainbread 2" ]||[ "${gamename}" == "Don't Starve Together" ]; then array_deps_required+=( libcurl.i686 ) - # Project Zomboid - elif [ "${engine}" == "projectzomboid" ]; then + # Project Zomboid and Minecraft + elif [ "${engine}" == "projectzomboid" ]||[ "${engine}" == "lwjgl2" ]; then array_deps_required+=( java-1.8.0-openjdk ) # Unreal Engine elif [ "${executable}" == "./ucc-bin" ]; then diff --git a/lgsm/functions/check_glibc.sh b/lgsm/functions/check_glibc.sh index 2fcd6e8a1..85caf6d01 100644 --- a/lgsm/functions/check_glibc.sh +++ b/lgsm/functions/check_glibc.sh @@ -35,7 +35,7 @@ elif [ "$(printf '%s\n'${glibcrequired}'\n' ${glibcversion} | sort -V | head -n echo -e " * glibc required: ${glibcrequired}" echo -e " * glibc installed: ${red}${glibcversion}${default}" echo -en "\n" - fn_print_infomation "The game server will probably not work. A distro upgrade is required!" + fn_print_information "The game server will probably not work. A distro upgrade is required!" sleep 5 fi fi \ No newline at end of file diff --git a/lgsm/functions/check_ip.sh b/lgsm/functions/check_ip.sh index 0ba8bcbf3..1a64db6bd 100644 --- a/lgsm/functions/check_ip.sh +++ b/lgsm/functions/check_ip.sh @@ -24,7 +24,7 @@ if [ "${gamename}" != "TeamSpeak 3" ] && [ "${gamename}" != "Mumble" ]; then fn_print_fail "Check IP: Multiple active network interfaces found." sleep 1 echo -en "\n" - fn_print_infomation "Specify the IP you want to use within the ${selfname} script.\n" + fn_print_information "Specify the IP you want to use within the ${selfname} script.\n" echo -en "Set ip=\"0.0.0.0\" to one of the following:\n" echo -en "${getip}\n" echo -en "" diff --git a/lgsm/functions/check_permissions.sh b/lgsm/functions/check_permissions.sh index c41f8d67f..297bf16d6 100644 --- a/lgsm/functions/check_permissions.sh +++ b/lgsm/functions/check_permissions.sh @@ -9,19 +9,44 @@ local commandname="CHECK" local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_check_ownership(){ + if [ -f "${rootdir}/${selfname}" ]; then + if [ $(find "${rootdir}/${selfname}" -not -user $(whoami)|wc -l) -ne "0" ]; then + selfownissue=1 + fi + fi + if [ -d "${functionsdir}" ]; then + if [ $(find "${functionsdir}" -not -user $(whoami)|wc -l) -ne "0" ]; then + funcownissue=1 + fi + fi if [ -d "${filesdir}" ]; then - if [ $(find "${filesdir}" -not -user $(whoami)|wc -l) -ne "0" ]||[ $(find "${rootdir}/${selfname}" -not -user $(whoami)|wc -l) -ne "0" ]; then - fn_print_fail_nl "Permissions issues found" - fn_script_log_fatal "Permissions issues found" - fn_print_infomation_nl "The current user ($(whoami)) does not have ownership of the following files:" - fn_script_log_info "The current user ($(whoami)) does not have ownership of the following files:" - { - echo -e "User\tGroup\tFile\n" - find "${filesdir}" -not -user $(whoami) -printf "%u\t\t%g\t%p\n" - } | column -s $'\t' -t | tee -a "${scriptlog}" - core_exit.sh + if [ $(find "${filesdir}" -not -user $(whoami)|wc -l) -ne "0" ]; then + filesownissue=1 fi fi + if [ "${selfownissue}" == "1" ]||[ "${funcownissue}" == "1" ]||[ "${filesownissue}" == "1" ]; then + fn_print_fail_nl "Ownership issues found" + fn_script_log_fatal "Ownership issues found" + fn_print_information_nl "The current user ($(whoami)) does not have ownership of the following files:" + fn_script_log_info "The current user ($(whoami)) does not have ownership of the following files:" + { + echo -e "User\tGroup\tFile\n" + if [ "${selfownissue}" == "1" ]; then + find "${rootdir}/${selfname}" -not -user $(whoami) -printf "%u\t\t%g\t%p\n" + fi + if [ "${funcownissue}" == "1" ]; then + find "${functionsdir}" -not -user $(whoami) -printf "%u\t\t%g\t%p\n" + fi + if [ "${funcownissue}" == "1" ]; then + find "${filesdir}" -not -user $(whoami) -printf "%u\t\t%g\t%p\n" + fi + + } | column -s $'\t' -t | tee -a "${scriptlog}" + echo "" + fn_print_information_nl "For more information, please see https://github.com/GameServerManagers/LinuxGSM/wiki/FAQ#-fail--starting-game-server-permissions-issues-found" + fn_script_log "For more information, please see https://github.com/GameServerManagers/LinuxGSM/wiki/FAQ#-fail--starting-game-server-permissions-issues-found" + core_exit.sh + fi } fn_check_permissions(){ @@ -29,7 +54,7 @@ fn_check_permissions(){ if [ $(find "${functionsdir}" -type f -not -executable|wc -l) -ne "0" ]; then fn_print_fail_nl "Permissions issues found" fn_script_log_fatal "Permissions issues found" - fn_print_infomation_nl "The following files are not executable:" + fn_print_information_nl "The following files are not executable:" fn_script_log_info "The following files are not executable:" { echo -e "File\n" @@ -49,7 +74,7 @@ fn_check_permissions(){ if [ "${userrootdirperm}" != "7" ] && [ "${grouprootdirperm}" != "7" ]; then fn_print_fail_nl "Permissions issues found" fn_script_log_fatal "Permissions issues found" - fn_print_infomation_nl "The following directorys does not have the correct permissions:" + fn_print_information_nl "The following directorys does not have the correct permissions:" fn_script_log_info "The following directorys does not have the correct permissions:" ls -l "${rootdir}" core_exit.sh diff --git a/lgsm/functions/check_steamcmd.sh b/lgsm/functions/check_steamcmd.sh index 01da9cda2..1e0f66cd7 100644 --- a/lgsm/functions/check_steamcmd.sh +++ b/lgsm/functions/check_steamcmd.sh @@ -51,7 +51,7 @@ fn_check_steamcmd_sh(){ fn_install_steamcmd fi elif [ "${function_selfname}" == "command_install.sh" ]; then - fn_print_infomation "SteamCMD is already installed..." + fn_print_information "SteamCMD is already installed..." fn_print_ok_eol_nl fi } diff --git a/lgsm/functions/check_system_requirements.sh b/lgsm/functions/check_system_requirements.sh index 1d735642d..a46c3d0e3 100644 --- a/lgsm/functions/check_system_requirements.sh +++ b/lgsm/functions/check_system_requirements.sh @@ -21,6 +21,11 @@ if [ "${gamename}" == "ARMA 3" ]; then ramrequirementgb="1" fi +if [ "${gamename}" == "Minecraft" ]; then + ramrequirementmb="1000" + ramrequirementgb="1" +fi + # If the game or engine has a minimum RAM Requirement, compare it to system's available RAM. if [ -n "${ramrequirementmb}" ]; then if [ "${physmemtotalmb}" -lt "${ramrequirementmb}" ]; then diff --git a/lgsm/functions/command_details.sh b/lgsm/functions/command_details.sh index cbac77f7a..fb3531cc3 100644 --- a/lgsm/functions/command_details.sh +++ b/lgsm/functions/command_details.sh @@ -3,7 +3,7 @@ # Author: Daniel Gibbs # Contributor: UltimateByte # Website: https://gameservermanagers.com -# Description: Displays server infomation. +# Description: Displays server information. local commandname="DETAILS" local commandaction="Details" @@ -106,7 +106,9 @@ fn_details_gameserver(){ printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = { # Server name - echo -e "${blue}Server name:\t${default}${servername}" + if [ -n "${servername}" ]; then + echo -e "${blue}Server name:\t${default}${servername}" + fi # Server ip echo -e "${blue}Server IP:\t${default}${ip}:${port}" @@ -287,14 +289,15 @@ fn_details_ports(){ echo -e "Change ports by editing the parameters in:" parmslocation="${red}UNKNOWN${default}" - local ports_edit_array=( "avalanche" "dontstarve" "projectzomboid" "idtech3" "realvirtuality" "seriousengine35" "teeworlds" "terraria" "unreal" "unreal2" "TeamSpeak 3" "Mumble" "7 Days To Die" ) + # engines that require editing in the config file + local ports_edit_array=( "avalanche" "dontstarve" "idtech3" "lwjgl2" "projectzomboid" "realvirtuality" "seriousengine35" "teeworlds" "terraria" "unreal" "unreal2" "TeamSpeak 3" "Mumble" "7 Days To Die" ) for port_edit in "${ports_edit_array[@]}" do if [ "${engine}" == "${port_edit}" ]||[ "${gamename}" == "${port_edit}" ]; then parmslocation="${servercfgfullpath}" fi done - + # engines that require editing in the script file local ports_edit_array=( "starbound" "spark" "source" "goldsource" "Rust" "Hurtworld" "unreal4") for port_edit in "${ports_edit_array[@]}" do @@ -337,6 +340,15 @@ fn_details_dontstarve(){ } | column -s $'\t' -t } +fn_details_minecraft(){ + echo -e "netstat -atunp | grep java" + echo -e "" + { + echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL" + echo -e "> Game\tINBOUND\t${port}\tudp" + } | column -s $'\t' -t +} + fn_details_projectzomboid(){ echo -e "netstat -atunp | grep java" echo -e "" @@ -591,6 +603,8 @@ if [ "${engine}" == "avalanche" ]; then fn_details_avalanche elif [ "${engine}" == "dontstarve" ]; then fn_details_dontstarve +elif [ "${engine}" == "lwjgl2" ]; then + fn_details_minecraft elif [ "${engine}" == "projectzomboid" ]; then fn_details_projectzomboid elif [ "${engine}" == "idtech3" ]; then diff --git a/lgsm/functions/command_install.sh b/lgsm/functions/command_install.sh index 698aec70b..b4beceed4 100644 --- a/lgsm/functions/command_install.sh +++ b/lgsm/functions/command_install.sh @@ -18,7 +18,7 @@ check_deps.sh if [ "${gamename}" == "Unreal Tournament 2004" ]; then install_server_files.sh install_ut2k4_key.sh -elif [ "${gamename}" == "Unreal Tournament 3" ]||[ "${gamename}" == "Battlefield: 1942" ]||[ "${gamename}" == "Enemy Territory" ]||[ "${gamename}" == "Unreal Tournament 99" ]||[ "${gamename}" == "Unreal Tournament" ]||[ "${gamename}" == "TeamSpeak 3" ]||[ "${gamename}" == "Mumble" ]; then +elif [ "${gamename}" == "Unreal Tournament 3" ]||[ "${gamename}" == "Battlefield: 1942" ]||[ "${gamename}" == "Enemy Territory" ]||[ "${gamename}" == "Unreal Tournament 99" ]||[ "${gamename}" == "Unreal Tournament" ]||[ "${gamename}" == "TeamSpeak 3" ]||[ "${gamename}" == "Minecraft" ]||[ "${gamename}" == "Mumble" ]; then installer=1 install_server_files.sh elif [ -n "${appid}" ]; then diff --git a/lgsm/functions/command_stop.sh b/lgsm/functions/command_stop.sh index 572225c18..a98246b63 100644 --- a/lgsm/functions/command_stop.sh +++ b/lgsm/functions/command_stop.sh @@ -9,7 +9,7 @@ local commandname="STOP" local commandaction="Stopping" local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" -# Attempts Graceful of source using rcon 'quit' command. +# Attempts graceful of source using rcon 'quit' command. fn_stop_graceful_source(){ fn_print_dots "Graceful: rcon quit" fn_script_log_info "Graceful: rcon quit" @@ -37,7 +37,7 @@ fn_stop_graceful_source(){ fn_stop_tmux } -# Attempts Graceful of goldsource using rcon 'quit' command. +# Attempts graceful of goldsource using rcon 'quit' command. # Goldsource 'quit' command restarts rather than shutsdown # this function will only wait 3 seconds then force a tmux shutdown. # preventing the server from coming back online. @@ -58,7 +58,7 @@ fn_stop_graceful_goldsource(){ fn_stop_tmux } -# Attempts Graceful of 7 Days To Die using telnet. +# Attempts graceful of 7 Days To Die using telnet. fn_stop_telnet_sdtd(){ sdtd_telnet_shutdown=$( expect -c ' proc abort {} { @@ -144,6 +144,34 @@ fn_stop_graceful_sdtd(){ fn_stop_tmux } +# Attempts graceful of source using rcon '/stop' command. +fn_stop_graceful_minecraft(){ + fn_print_dots "Graceful: console /stop" + fn_script_log_info "Graceful: console /stop" + # sends quit + tmux send -t "${servicename}" /stop ENTER > /dev/null 2>&1 + # waits up to 30 seconds giving the server time to shutdown gracefuly + for seconds in {1..30}; do + check_status.sh + if [ "${status}" == "0" ]; then + fn_print_ok "Graceful: console /stop: ${seconds}: " + fn_print_ok_eol_nl + fn_script_log_pass "Graceful: console /stop: OK: ${seconds} seconds" + break + fi + sleep 1 + fn_print_dots "Graceful: console /stop: ${seconds}" + done + check_status.sh + if [ "${status}" != "0" ]; then + fn_print_error "Graceful: console /stop: " + fn_print_fail_eol_nl + fn_script_log_error "Graceful: console /stop: FAIL" + fi + sleep 1 + fn_stop_tmux +} + fn_stop_graceful_select(){ if [ "${gamename}" == "7 Days To Die" ]; then fn_stop_graceful_sdtd @@ -151,6 +179,8 @@ fn_stop_graceful_select(){ fn_stop_graceful_source elif [ "${engine}" == "goldsource" ]; then fn_stop_graceful_goldsource + elif [ "${engine}" == "lwjgl2" ]; then + fn_stop_graceful_minecraft else fn_stop_tmux fi diff --git a/lgsm/functions/command_ts3_server_pass.sh b/lgsm/functions/command_ts3_server_pass.sh index e260b8a2a..89c3cd036 100644 --- a/lgsm/functions/command_ts3_server_pass.sh +++ b/lgsm/functions/command_ts3_server_pass.sh @@ -16,7 +16,7 @@ fn_serveradmin_password_prompt(){ echo "=================================" echo "" echo "Press \"CTRL+b d\" to exit console." - fn_print_infomation_nl "You are about to change the ${gamename} ServerAdmin password." + fn_print_information_nl "You are about to change the ${gamename} ServerAdmin password." fn_print_warning_nl "${gamename} will restart during this process." echo "" while true; do diff --git a/lgsm/functions/command_update.sh b/lgsm/functions/command_update.sh index d282cc432..bffa4e6ea 100644 --- a/lgsm/functions/command_update.sh +++ b/lgsm/functions/command_update.sh @@ -15,6 +15,8 @@ check.sh if [ "${gamename}" == "TeamSpeak 3" ]; then update_ts3.sh +elif [ "${engine}" == "lwjgl2" ]; then + update_minecraft.sh elif [ "${gamename}" == "Mumble" ]; then update_mumble.sh else diff --git a/lgsm/functions/core_dl.sh b/lgsm/functions/core_dl.sh index 0c1e0a76b..e6e563fc7 100644 --- a/lgsm/functions/core_dl.sh +++ b/lgsm/functions/core_dl.sh @@ -117,7 +117,7 @@ fn_fetch_file(){ # trap to remove part downloaded files trap fn_fetch_trap INT # if larger file shows progress bar - if [ ${filename##*.} == "bz2" ]; then + if [ ${filename##*.} == "bz2" ]||[ ${filename##*.} == "jar" ]; then echo -ne "downloading ${filename}..." sleep 1 curlcmd=$(${curlcmd} --progress-bar --fail -L -o "${filedir}/${filename}" "${fileurl}") diff --git a/lgsm/functions/core_functions.sh b/lgsm/functions/core_functions.sh index d178f6eb3..73f8bd44d 100644 --- a/lgsm/functions/core_functions.sh +++ b/lgsm/functions/core_functions.sh @@ -400,6 +400,11 @@ functionfile="${FUNCNAME}" fn_fetch_function } +update_minecraft.sh(){ +functionfile="${FUNCNAME}" +fn_fetch_function +} + update_mumble.sh(){ functionfile="${FUNCNAME}" fn_fetch_function @@ -455,6 +460,11 @@ functionfile="${FUNCNAME}" fn_fetch_function } +install_minecraft_eula.sh(){ +functionfile="${FUNCNAME}" +fn_fetch_function +} + install_retry.sh(){ functionfile="${FUNCNAME}" fn_fetch_function diff --git a/lgsm/functions/core_getopt.sh b/lgsm/functions/core_getopt.sh index 4c6514bdd..26aa8ec7c 100644 --- a/lgsm/functions/core_getopt.sh +++ b/lgsm/functions/core_getopt.sh @@ -41,7 +41,7 @@ case "${getopt}" in command_install.sh;; ai|auto-install) fn_autoinstall;; - dd|depsdetect) + dd|deps-detect) command_dev_detect_deps.sh;; dg|detect-glibc) command_dev_detect_glibc.sh;; @@ -65,7 +65,7 @@ case "${getopt}" in echo -e "${blue}validate\t${default}v |Validate server files with SteamCMD." echo -e "${blue}monitor\t${default}m |Checks that the server is running." echo -e "${blue}test-alert\t${default}ta |Sends test alert." - echo -e "${blue}details\t${default}dt |Displays useful infomation about the server." + echo -e "${blue}details\t${default}dt |Displays useful information about the server." echo -e "${blue}backup\t${default}b |Create archive of the server." echo -e "${blue}console\t${default}c |Console allows you to access the live view of a server." echo -e "${blue}debug\t${default}d |See the output of the server directly to your terminal." @@ -103,7 +103,7 @@ case "${getopt}" in command_install.sh;; ai|auto-install) fn_autoinstall;; - dd|depsdetect) + dd|deps-detect) command_dev_detect_deps.sh;; dg|detect-glibc) command_dev_detect_glibc.sh;; @@ -125,7 +125,7 @@ case "${getopt}" in echo -e "${blue}update-functions\t${default}uf |Removes all functions so latest can be downloaded." echo -e "${blue}monitor\t${default}m |Checks that the server is running." echo -e "${blue}test-alert\t${default}ta |Sends test alert." - echo -e "${blue}details\t${default}dt |Displays useful infomation about the server." + echo -e "${blue}details\t${default}dt |Displays useful information about the server." echo -e "${blue}change-password\t${default}pw |Changes TS3 serveradmin password." echo -e "${blue}backup\t${default}b |Create archive of the server." echo -e "${blue}install\t${default}i |Install the server." @@ -134,6 +134,68 @@ case "${getopt}" in esac } +fn_getopt_minecraft(){ +case "${getopt}" in + st|start) + command_start.sh;; + sp|stop) + command_stop.sh;; + r|restart) + command_restart.sh;; + u|update) + command_update.sh;; + uf|update-functions) + command_update_functions.sh;; + m|monitor) + command_monitor.sh;; + ta|test-alert) + command_test_alert.sh;; + dt|details) + command_details.sh;; + b|backup) + command_backup.sh;; + c|console) + command_console.sh;; + d|debug) + command_debug.sh;; + dev|dev-debug) + command_dev_debug.sh;; + i|install) + command_install.sh;; + ai|auto-install) + fn_autoinstall;; + dd|deps-detect) + command_dev_detect_deps.sh;; + dg|detect-glibc) + command_dev_detect_glibc.sh;; + *) + if [ -n "${getopt}" ]; then + echo -e "${red}Unknown command${default}: $0 ${getopt}" + exitcode=2 + fi + echo "Usage: $0 [option]" + echo "${gamename} - Linux Game Server Manager - Version ${version}" + echo "https://gameservermanagers.com/${selfname}" + echo -e "" + echo -e "${lightyellow}Commands${default}" + { + echo -e "${blue}start\t${default}st |Start the server." + echo -e "${blue}stop\t${default}sp |Stop the server." + echo -e "${blue}restart\t${default}r |Restart the server." + echo -e "${blue}update\t${default}u |Checks and applies updates from mojang.com." + echo -e "${blue}update-functions\t${default}uf |Removes all functions so latest can be downloaded." + echo -e "${blue}monitor\t${default}m |Checks that the server is running." + echo -e "${blue}test-alert\t${default}ta |Sends test alert." + echo -e "${blue}details\t${default}dt |Displays useful infomation about the server." + echo -e "${blue}backup\t${default}b |Create archive of the server." + echo -e "${blue}console\t${default}c |Console allows you to access the live view of a server." + echo -e "${blue}debug\t${default}d |See the output of the server directly to your terminal." + echo -e "${blue}install\t${default}i |Install the server." + echo -e "${blue}auto-install\t${default}ai |Install the server, without prompts." + } | column -s $'\t' -t + esac +} + fn_getopt_mumble(){ case "${getopt}" in st|start) @@ -158,7 +220,7 @@ case "${getopt}" in command_dev_debug.sh;; i|install) command_install.sh;; - dd|depsdetect) + dd|deps-detect) command_dev_detect_deps.sh;; dg|detect-glibc) command_dev_detect_glibc.sh;; @@ -180,7 +242,7 @@ case "${getopt}" in echo -e "${blue}update-functions\t${default}uf |Removes all functions so latest can be downloaded." echo -e "${blue}monitor\t${default}m |Checks that the server is running." echo -e "${blue}test-alert\t${default}ta |Sends test alert." - echo -e "${blue}details\t${default}dt |Displays useful infomation about the server." + echo -e "${blue}details\t${default}dt |Displays useful information about the server." echo -e "${blue}backup\t${default}b |Create archive of the server." echo -e "${blue}install\t${default}i |Install the server." } | column -s $'\t' -t @@ -222,7 +284,7 @@ case "${getopt}" in command_install.sh;; ai|auto-install) fn_autoinstall;; - dd|depsdetect) + dd|deps-detect) command_dev_detect_deps.sh;; dg|detect-glibc) command_dev_detect_glibc.sh;; @@ -248,7 +310,7 @@ case "${getopt}" in echo -e "${blue}validate\t${default}v |Validate server files with SteamCMD." echo -e "${blue}monitor\t${default}m |Checks that the server is running." echo -e "${blue}test-alert\t${default}ta |Sends test alert." - echo -e "${blue}details\t${default}dt |Displays useful infomation about the server." + echo -e "${blue}details\t${default}dt |Displays useful information about the server." echo -e "${blue}backup\t${default}b |Create archive of the server." echo -e "${blue}console\t${default}c |Console allows you to access the live view of a server." echo -e "${blue}debug\t${default}d |See the output of the server directly to your terminal." @@ -289,7 +351,7 @@ case "${getopt}" in fn_autoinstall;; mc|map-compressor) compress_ut99_maps.sh;; - dd|depsdetect) + dd|deps-detect) command_dev_detect_deps.sh;; dg|detect-glibc) command_dev_detect_glibc.sh;; @@ -310,7 +372,7 @@ case "${getopt}" in echo -e "${blue}update-functions\t${default}uf |Removes all functions so latest can be downloaded." echo -e "${blue}monitor\t${default}m |Checks that the server is running." echo -e "${blue}test-alert\t${default}ta |Sends test alert." - echo -e "${blue}details\t${default}dt |Displays useful infomation about the server." + echo -e "${blue}details\t${default}dt |Displays useful information about the server." echo -e "${blue}backup\t${default}b |Create archive of the server." echo -e "${blue}console\t${default}c |Console allows you to access the live view of a server." echo -e "${blue}debug\t${default}d |See the output of the server directly to your terminal." @@ -357,7 +419,7 @@ case "${getopt}" in command_install.sh;; ai|auto-install) fn_autoinstall;; - dd|depsdetect) + dd|deps-detect) command_dev_detect_deps.sh;; dg|detect-glibc) command_dev_detect_glibc.sh;; @@ -383,7 +445,7 @@ case "${getopt}" in echo -e "${blue}validate\t${default}v |Validate server files with SteamCMD." echo -e "${blue}monitor\t${default}m |Checks that the server is running." echo -e "${blue}test-alert\t${default}ta |Sends test alert." - echo -e "${blue}details\t${default}dt |Displays useful infomation about the server." + echo -e "${blue}details\t${default}dt |Displays useful information about the server." echo -e "${blue}backup\t${default}b |Create archive of the server." echo -e "${blue}console\t${default}c |Console allows you to access the live view of a server." echo -e "${blue}debug\t${default}d |See the output of the server directly to your terminal." @@ -427,7 +489,7 @@ case "${getopt}" in install_ut2k4_key.sh;; mc|map-compressor) compress_unreal2_maps.sh;; - dd|depsdetect) + dd|deps-detect) command_dev_detect_deps.sh;; dg|detect-glibc) command_dev_detect_glibc.sh;; @@ -448,7 +510,7 @@ case "${getopt}" in echo -e "${blue}update-functions\t${default}uf |Removes all functions so latest can be downloaded." echo -e "${blue}monitor\t${default}m |Checks that the server is running." echo -e "${blue}test-alert\t${default}ta |Sends test alert." - echo -e "${blue}details\t${default}dt |Displays useful infomation about the server." + echo -e "${blue}details\t${default}dt |Displays useful information about the server." echo -e "${blue}backup\t${default}b |Create archive of the server." echo -e "${blue}console\t${default}c |Console allows you to access the live view of a server." echo -e "${blue}debug\t${default}d |See the output of the server directly to your terminal." @@ -462,6 +524,8 @@ case "${getopt}" in if [ "${gamename}" == "Mumble" ]; then fn_getopt_mumble +elif [ "${engine}" == "lwjgl2" ]; then + fn_getopt_minecraft elif [ "${gamename}" == "TeamSpeak 3" ]; then fn_getopt_teamspeak3 elif [ "${gamename}" == "Garry's Mod" ]; then diff --git a/lgsm/functions/core_messages.sh b/lgsm/functions/core_messages.sh index 97f609f50..d23733cde 100644 --- a/lgsm/functions/core_messages.sh +++ b/lgsm/functions/core_messages.sh @@ -249,13 +249,13 @@ fn_print_warning_nl(){ echo -e "${yellow}Warning!${default} $@" } -# Infomation! -fn_print_infomation(){ - echo -en "${cyan}Infomation!${default} $@" +# Information! +fn_print_information(){ + echo -en "${cyan}Information!${default} $@" } -fn_print_infomation_nl(){ - echo -e "${cyan}Infomation!${default} $@" +fn_print_information_nl(){ + echo -e "${cyan}Information!${default} $@" } # On-Screen End of Line diff --git a/lgsm/functions/info_config.sh b/lgsm/functions/info_config.sh index 1f754d62d..6c868d047 100644 --- a/lgsm/functions/info_config.sh +++ b/lgsm/functions/info_config.sh @@ -10,7 +10,7 @@ local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" ## Examples of filtering to get info from config files # sed 's/foo//g' - remove foo # tr -cd '[:digit:]' leave only digits -# tr -d '=\"; ' remove selected charectors =\"; +# tr -d '=\"; ' remove selected characters =\"; # grep -v "foo" filter out lines that contain foo unavailable="${red}UNAVAILABLE${default}" @@ -68,6 +68,37 @@ fn_info_config_dontstarve(){ fi } +fn_info_config_minecraft(){ + if [ ! -f "${servercfgfullpath}" ]; then + rconpassword="${unavailable}" + rconport="${zero}" + slots="${zero}" + port="${zero}" + gamemode="${zero}" + gameworld="${unavailable}" + else + # check if the ip exists in the config file. Failing this will fall back to the default. + ipconfigcheck=$(grep "server-ip=" "${servercfgfullpath}" | sed 's/server-ip=//g') + if [ -n "${ipconfigcheck}" ]; then + ip="${ipconfigcheck}" + fi + rconpassword=$(grep "rcon.password=" "${servercfgfullpath}" | sed 's/rcon.password=//g' | tr -d '=\"; ') + rconport=$(grep "rcon.port=" "${servercfgfullpath}" | tr -cd '[:digit:]') + slots=$(grep "max-players=" "${servercfgfullpath}" | tr -cd '[:digit:]') + port=$(grep "server-port=" "${servercfgfullpath}" | tr -cd '[:digit:]') + gamemode=$(grep "gamemode=" "${servercfgfullpath}" | tr -cd '[:digit:]') + gameworld=$(grep "level-name=" "${servercfgfullpath}" | sed 's/level-name=//g' | tr -d '=\"; ') + + # Not Set + rconpassword=${rconpassword:-"NOT SET"} + rconport=${rconport:-"NOT SET"} + slots=${slots:-"NOT SET"} + port=${port:-"NOT SET"} + gamemode=${gamemode:-"NOT SET"} + gameworld=${gameworld:-"NOT SET"} + fi +} + fn_info_config_projectzomboid(){ if [ ! -f "${servercfgfullpath}" ]; then servername="${unavailable}" @@ -77,9 +108,9 @@ fn_info_config_projectzomboid(){ port="${zero}" gameworld="${unavailable}" else - servername=$(grep "PublicName=" "${servercfgfullpath}" | sed 's/PublicName=//g' | tr -d '\') - serverpassword=$(grep "^Password=$" "${servercfgfullpath}" | sed 's/Password=//g' | tr -d '\') - rconpassword=$(grep "RCONPassword=" "${servercfgfullpath}" | sed 's/RCONPassword=//g' | tr -d '\') + servername=$(grep "PublicName=" "${servercfgfullpath}" | sed 's/PublicName=//g' | tr -d '=\";\n') + serverpassword=$(grep "^Password=$" "${servercfgfullpath}" | sed 's/Password=//g' | tr -d '=\"; ') + rconpassword=$(grep "RCONPassword=" "${servercfgfullpath}" | sed 's/RCONPassword=//g' | tr -d '=\"; ') slots=$(grep "MaxPlayers=" "${servercfgfullpath}" | grep -v "#" | tr -cd '[:digit:]') port=$(grep "DefaultPort=" "${servercfgfullpath}" | tr -cd '[:digit:]') gameworld=$(grep "Map=" "${servercfgfullpath}" | sed 's/Map=//g' | tr -d '\n') @@ -374,18 +405,22 @@ fn_info_config_sdtd(){ gameworld=${gameworld:-"NOT SET"} fi } -## Just Cause 2 + +# Just Cause 2 if [ "${engine}" == "avalanche" ]; then fn_info_config_avalanche -## Dont Starve Together +# Dont Starve Together elif [ "${engine}" == "dontstarve" ]; then fn_info_config_dontstarve -## Project Zomboid -elif [ "${engine}" == "projectzomboid" ]; then - fn_info_config_projectzomboid # Quake Love elif [ "${engine}" == "idtech3" ]; then fn_info_config_idtech3 +# Minecraft +elif [ "${engine}" == "lwjgl2" ]; then + fn_info_config_minecraft +# Project Zomboid +elif [ "${engine}" == "projectzomboid" ]; then + fn_info_config_projectzomboid # ARMA 3 elif [ "${engine}" == "realvirtuality" ]; then fn_info_config_realvirtuality diff --git a/lgsm/functions/info_distro.sh b/lgsm/functions/info_distro.sh index 4f3012730..a203a2c47 100644 --- a/lgsm/functions/info_distro.sh +++ b/lgsm/functions/info_distro.sh @@ -7,7 +7,7 @@ local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" -### Distro infomation +### Distro information ## Distro # Returns architecture, kernel and distro/os. @@ -53,12 +53,12 @@ hours=$(( uptime/60/60%24 )) days=$(( uptime/60/60/24 )) -### Performance infomation +### Performance information ## Average server load load=$(uptime|awk -F 'load average: ' '{ print $2 }') -## Memory Infomation +## Memory information # Available RAM and swap. # Older versions of free do not support -h option. @@ -77,7 +77,7 @@ swaptotal=$(free ${humanreadable} | awk '/Swap:/ {print $2}') swapused=$(free ${humanreadable} | awk '/Swap:/ {print $3}') swapfree=$(free ${humanreadable} | awk '/Swap:/ {print $4}') -### Disk Infomation +### Disk information ## Available disk space on the partition. filesystem=$(df -hP "${rootdir}" | grep -v "Filesystem" | awk '{print $1}') diff --git a/lgsm/functions/info_glibc.sh b/lgsm/functions/info_glibc.sh index e5a55be0f..a1916944f 100644 --- a/lgsm/functions/info_glibc.sh +++ b/lgsm/functions/info_glibc.sh @@ -29,18 +29,27 @@ elif [ "${gamename}" == "Garry's Mod" ]; then elif [ "${gamename}" == "Insurgency" ]; then glibcrequired="2.15" glibcfix="yes" +elif [ "${gamename}" == "Mumble" ]; then + glibcrequired="NOT REQUIRED" + glibcfix="no" elif [ "${gamename}" == "No More Room in Hell" ]; then glibcrequired="2.15" glibcfix="yes" elif [ "${gamename}" == "Quake Live" ]; then glibcrequired="2.15" glibcfix="no" +elif [ "${gamename}" == "TeamSpeak 3" ]; then + glibcrequired="NOT REQUIRED" + glibcfix="no" elif [ "${engine}" == "avalanche" ]; then glibcrequired="2.13" glibcfix="yes" elif [ "${engine}" == "dontstarve" ]; then glibcrequired="2.15" glibcfix="no" +elif [ "${engine}" == "lwjgl2" ]; then + glibcrequired="NOT REQUIRED" + glibcfix="no" elif [ "${engine}" == "projectzomboid" ]; then glibcrequired="2.15" glibcfix="no" diff --git a/lgsm/functions/install_config.sh b/lgsm/functions/install_config.sh index 26bef215c..1aafd1602 100644 --- a/lgsm/functions/install_config.sh +++ b/lgsm/functions/install_config.sh @@ -359,6 +359,11 @@ elif [ "${gamename}" == "Left 4 Dead 2" ]; then wget -N /dev/null ${githuburl}/Left4Dead2/cfg/lgsm-default.cfg 2>&1 | grep -F HTTP | cut -c45- | uniq sleep 1 fn_sourceconfig +elif [ "${gamename}" == "Minecraft" ]; then + echo -e "downloading lgsm-default.ini...\c" + wget -N /dev/null ${githuburl}/Minecraft/cfg/lgsm-default.ini 2>&1 | grep -F HTTP | cut -c45- | uniq + sleep 1 + fn_defaultconfig elif [ "${gamename}" == "No More Room in Hell" ]; then echo -e "downloading lgsm-default.cfg...\c" wget -N /dev/null ${githuburl}/NoMoreRoomInHell/cfg/lgsm-default.cfg 2>&1 | grep -F HTTP | cut -c45- | uniq diff --git a/lgsm/functions/install_minecraft_eula.sh b/lgsm/functions/install_minecraft_eula.sh new file mode 100644 index 000000000..410e283b4 --- /dev/null +++ b/lgsm/functions/install_minecraft_eula.sh @@ -0,0 +1,33 @@ +#!/bin/bash +# LGSM install_minecraft_eula.sh function +# Author: Daniel Gibbs +# Website: https://gameservermanagers.com +# Description: Gets user to accept the EULA. + +echo "" +echo "Accept ${gamename} EULA" +echo "=================================" +sleep 1 +echo "You are required to accept the EULA:" +echo "https://account.mojang.com/documents/minecraft_eula" + +echo "eula=false" > "${filesdir}/eula.txt" + +if [ -z "${autoinstall}" ]; then +echo "By continuing you are indicating your agreement to the EULA." +echo "" + while true; do + read -e -i "y" -p "Continue [Y/n]" yn + case $yn in + [Yy]* ) break;; + [Nn]* ) core_exit.sh;; + * ) echo "Please answer yes or no.";; + esac + done +else +echo "By using auto-install you are indicating your agreement to the EULA." +echo "" + sleep 5 +fi + +sed -i "s/eula=false/eula=true/g" "${filesdir}/eula.txt" \ No newline at end of file diff --git a/lgsm/functions/install_server_files.sh b/lgsm/functions/install_server_files.sh index dfe07777d..d26efd2cb 100644 --- a/lgsm/functions/install_server_files.sh +++ b/lgsm/functions/install_server_files.sh @@ -86,7 +86,7 @@ fn_install_server_files_steamcmd(){ # Goldsource servers commonly fail to download all the server files required. # Validating a few of times may reduce the chance of this issue. if [ "${engine}" == "goldsource" ]; then - fn_print_infomation_nl "Goldsource servers commonly fail to download all the server files required. Validating a few of times may reduce the chance of this issue." + fn_print_information_nl "Goldsource servers commonly fail to download all the server files required. Validating a few of times may reduce the chance of this issue." counter="0" while [ "${counter}" -le "4" ]; do counter=$((counter+1)) @@ -103,6 +103,9 @@ sleep 1 if [ "${gamename}" == "TeamSpeak 3" ]; then update_ts3.sh +elif [ "${gamename}" == "Minecraft" ]; then + update_minecraft.sh + install_minecraft_eula.sh elif [ "${gamename}" == "Mumble" ]; then update_mumble.sh elif [ -z "${appid}" ]||[ "${gamename}" == "GoldenEye: Source" ]; then diff --git a/lgsm/functions/update_minecraft.sh b/lgsm/functions/update_minecraft.sh new file mode 100644 index 000000000..f4e140d6e --- /dev/null +++ b/lgsm/functions/update_minecraft.sh @@ -0,0 +1,157 @@ +#!/bin/bash +# LGSM update_minecraft.sh function +# Author: Daniel Gibbs +# Website: https://gameservermanagers.com +# Description: Handles updating of Minecraft servers. + +local commandname="UPDATE" +local commandaction="Update" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" + +fn_update_dl(){ + fn_fetch_file "https://s3.amazonaws.com/Minecraft.Download/versions/${availablebuild}/minecraft_server.${availablebuild}.jar" "${lgsmdir}/tmp" "minecraft_server.${availablebuild}.jar" + echo -e "copying to ${filesdir}...\c" + fn_script_log "Copying to ${filesdir}" + cp "${lgsmdir}/tmp/minecraft_server.${availablebuild}.jar" "${filesdir}/minecraft_server.jar" + local exitcode=$? + if [ ${exitcode} -eq 0 ]; then + fn_print_ok_eol_nl + else + fn_print_fail_eol_nl + fi +} + +fn_update_currentbuild(){ + # Gets current build info + # Checks if current build info is available. If it fails, then a server restart will be forced to generate logs. + if [ ! -f "${consolelogdir}/${servicename}-console.log" ]; then + fn_print_error "Checking for update: mojang.com" + sleep 1 + fn_print_error_nl "Checking for update: mojang.com: No logs with server version found" + fn_script_log_error "Checking for update: mojang.com: No logs with server version found" + sleep 1 + fn_print_info_nl "Checking for update: mojang.com: Forcing server restart" + fn_script_log_info "Checking for update: mojang.com: Forcing server restart" + sleep 1 + exitbypass=1 + command_stop.sh + exitbypass=1 + command_start.sh + sleep 1 + # Check again and exit on failure. + if [ ! -f "${consolelogdir}/${servicename}-console.log" ]; then + fn_print_fail_nl "Checking for update: mojang.com: Still No logs with server version found" + fn_script_log_fatal "Checking for update: mojang.com: Still No logs with server version found" + core_exit.sh + fi + fi + + # Get current build from logs + currentbuild=$(cat "${filesdir}/logs/latest.log" 2> /dev/null | grep version | egrep -o '((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}') + if [ -z "${currentbuild}" ]; then + fn_print_error_nl "Checking for update: mojang.com: Current build version not found" + fn_script_log_error "Checking for update: mojang.com: Current build version not found" + sleep 1 + fn_print_info_nl "Checking for update: mojang.com: Forcing server restart" + fn_script_log_info "Checking for update: mojang.com: Forcing server restart" + exitbypass=1 + command_stop.sh + exitbypass=1 + command_start.sh + currentbuild=$(cat "${filesdir}/logs/latest.log" 2> /dev/null | grep version | egrep -o '((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}') + if [ -z "${currentbuild}" ]; then + fn_print_fail_nl "Checking for update: mojang.com: Current build version still not found" + fn_script_log_fatal "Checking for update: mojang.com: Current build version still not found" + core_exit.sh + fi + fi +} + +fn_update_availablebuild(){ + # Gets latest build info. + availablebuild=$(curl -s "https://launchermeta.mojang.com/mc/game/version_manifest.json" | sed -e 's/^.*"release":"\([^"]*\)".*$/\1/') + sleep 1 + + # Checks if availablebuild variable has been set + if [ -z "${availablebuild}" ]; then + fn_print_fail "Checking for update: mojang.com" + sleep 1 + fn_print_fail "Checking for update: mojang.com: Not returning version info" + fn_script_log_fatal "Failure! Checking for update: mojang.com: Not returning version info" + core_exit.sh + else + fn_print_ok_nl "Checking for update: mojang.com" + fn_script_log_pass "Checking for update: mojang.com" + sleep 1 + fi +} + +fn_update_compare(){ + # Removes dots so if can compare version numbers + currentbuilddigit=$(echo "${currentbuild}"|tr -cd '[:digit:]') + availablebuilddigit=$(echo "${availablebuild}"|tr -cd '[:digit:]') + + if [ "${currentbuilddigit}" -ne "${availablebuilddigit}" ]; then + echo -e "\n" + echo -e "Update available:" + sleep 1 + echo -e " Current build: ${red}${currentbuild}${default}" + echo -e " Available build: ${green}${availablebuild}${default}" + echo -e "" + sleep 1 + echo "" + echo -en "Applying update.\r" + sleep 1 + echo -en "Applying update..\r" + sleep 1 + echo -en "Applying update...\r" + sleep 1 + echo -en "\n" + fn_script_log "Update available" + fn_script_log "Current build: ${currentbuild}" + fn_script_log "Available build: ${availablebuild}" + fn_script_log "${currentbuild} > ${availablebuild}" + + unset updateonstart + + check_status.sh + if [ "${status}" == "0" ]; then + fn_update_dl + exitbypass=1 + command_start.sh + exitbypass=1 + command_stop.sh + else + exitbypass=1 + command_stop.sh + fn_update_dl + exitbypass=1 + command_start.sh + fi + alert="update" + alert.sh + else + echo -e "\n" + echo -e "No update available:" + echo -e " Current version: ${green}${currentbuild}${default}" + echo -e " Available version: ${green}${availablebuild}${default}" + echo -e "" + fn_print_ok_nl "No update available" + fn_script_log_info "Current build: ${currentbuild}" + fn_script_log_info "Available build: ${availablebuild}" + fi +} + + +if [ "${installer}" == "1" ]; then + fn_update_availablebuild + fn_update_dl +else + # Checks for server update from mojang.com + fn_print_dots "Checking for update: mojang.com" + fn_script_log_info "Checking for update: mojang.com" + sleep 1 + fn_update_currentbuild + fn_update_availablebuild + fn_update_compare +fi diff --git a/lgsm/functions/update_mumble.sh b/lgsm/functions/update_mumble.sh index ba4b6f3ce..0a90384f7 100644 --- a/lgsm/functions/update_mumble.sh +++ b/lgsm/functions/update_mumble.sh @@ -87,7 +87,7 @@ fn_update_mumble_availablebuild(){ fn_script_log_fatal "Failure! Checking for update: GitHub: Not returning version info" core_exit.sh else - fn_print_ok_nl "Checking for update: GitHub" + fn_print_ok "Checking for update: GitHub" fn_script_log_pass "Checking for update: GitHub" sleep 1 fi diff --git a/lgsm/functions/update_ts3.sh b/lgsm/functions/update_ts3.sh index 9a6599942..6dfdced1a 100644 --- a/lgsm/functions/update_ts3.sh +++ b/lgsm/functions/update_ts3.sh @@ -119,7 +119,7 @@ fn_update_ts3_availablebuild(){ fn_script_log_fatal "Failure! Checking for update: teamspeak.com: Not returning version info" core_exit.sh else - fn_print_ok_nl "Checking for update: teamspeak.com" + fn_print_ok "Checking for update: teamspeak.com" fn_script_log_pass "Checking for update: teamspeak.com" sleep 1 fi