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..2f9dffa98 --- /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="mcserver" + +# 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 1f9d89488..90f4896ad 100644 --- a/lgsm/functions/check_deps.sh +++ b/lgsm/functions/check_deps.sh @@ -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 @@ -176,10 +176,10 @@ if [ -n "$(command -v dpkg-query)" ]; then # Brainbread 2 and Don't Starve Together elif [ "${gamename}" == "Brainbread 2" ]||[ "${gamename}" == "Don't Starve Together" ]; then array_deps_required+=( libcurl4-gnutls-dev: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 @@ -215,8 +215,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 @@ -234,8 +234,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_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 68680aaf2..fb3531cc3 100644 --- a/lgsm/functions/command_details.sh +++ b/lgsm/functions/command_details.sh @@ -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 5184d2871..94b597aae 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}" == "Enemy Territory" ]||[ "${gamename}" == "Unreal Tournament 99" ]||[ "${gamename}" == "Unreal Tournament" ]||[ "${gamename}" == "TeamSpeak 3" ]||[ "${gamename}" == "Mumble" ]; then +elif [ "${gamename}" == "Enemy Territory" ]||[ "${gamename}" == "Minecraft" ]||[ "${gamename}" == "Mumble" ]||[ "${gamename}" == "TeamSpeak 3" ]||[ "${gamename}" == "Unreal Tournament 99" ]||[ "${gamename}" == "Unreal Tournament" ]; 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_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 afb2dfc2b..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;; @@ -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;; @@ -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;; @@ -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;; @@ -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;; @@ -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;; @@ -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;; @@ -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/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_glibc.sh b/lgsm/functions/info_glibc.sh index 6ec3a6a96..d3662d08d 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 e23cac0a9..ed557e6eb 100644 --- a/lgsm/functions/install_config.sh +++ b/lgsm/functions/install_config.sh @@ -332,6 +332,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 0c33c22e1..a895a5868 100644 --- a/lgsm/functions/install_server_files.sh +++ b/lgsm/functions/install_server_files.sh @@ -99,6 +99,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