瀏覽代碼

Merge pull request #1024 from GameServerManagers/mcserver

Minecraft
Daniel Gibbs 9 年之前
父節點
當前提交
017e27552e

+ 40 - 0
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

+ 142 - 0
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

+ 10 - 10
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

+ 5 - 0
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

+ 17 - 3
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

+ 1 - 1
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

+ 33 - 3
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

+ 2 - 0
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

+ 1 - 1
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}")

+ 10 - 0
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

+ 71 - 7
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

+ 44 - 9
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

+ 9 - 0
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"

+ 5 - 0
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

+ 33 - 0
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"

+ 3 - 0
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

+ 157 - 0
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

+ 1 - 1
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

+ 1 - 1
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