diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..ef3ef8bd9 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,13 @@ +# EditorConfig helps developers define and maintain consistent coding styles between different editors and IDEs. +# Atom: Please assure your Atom's config setting Tab Type is set to auto, otherwise Atom-EditorConfig may not work as expected. Also disable whitespace package. +# http://editorconfig.org/ + +root = true + +[*] +charset = utf-8 +indent_style = tab +indent_size = 4 +trim_trailing_whitespace = true +end_of_line = lf +insert_final_newline = true diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 000000000..1387c5e19 --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,4 @@ +template: | + ## Changelog + + $CHANGES \ No newline at end of file diff --git a/.github/topissuebot.yml b/.github/topissuebot.yml new file mode 100644 index 000000000..b02540a2d --- /dev/null +++ b/.github/topissuebot.yml @@ -0,0 +1,4 @@ +# Configuration for top-issue-bot +labelName: ":thumbsup: Top Issue!" +labelColor: "f442c2" +numberOfIssuesToLabel: 5 \ No newline at end of file diff --git a/.github/write-good.yml b/.github/write-good.yml new file mode 100644 index 000000000..2bdb512ad --- /dev/null +++ b/.github/write-good.yml @@ -0,0 +1,4 @@ +# .github/write-good.yml +writeGood: true +alex: true +spellchecker: true \ No newline at end of file diff --git a/lgsm/config-default/config-lgsm/arkserver/_default.cfg b/lgsm/config-default/config-lgsm/arkserver/_default.cfg index e57c873d1..8c3ab71db 100644 --- a/lgsm/config-default/config-lgsm/arkserver/_default.cfg +++ b/lgsm/config-default/config-lgsm/arkserver/_default.cfg @@ -13,13 +13,13 @@ ip="0.0.0.0" port="7777" queryport="27015" rconport="27020" +# Default Map: TheIsland, Ragnarok, CrystalIsles, Aberration_P, ScorchedEarth_P defaultmap="TheIsland" maxplayers="70" ## Server Start Command | https://github.com/GameServerManagers/LinuxGSM/wiki/Start-Parameters#additional-parameters fn_parms(){ -parms="\"${defaultmap}?listen?MultiHome=${ip}?MaxPlayers=${maxplayers}?QueryPort=${queryport}?RCONPort=${rconport}?Port=${port}?\"" -} +parms="\"${defaultmap}?AltSaveDirectoryName=${defaultmap}?listen?MultiHome=${ip}?MaxPlayers=${maxplayers}?QueryPort=${queryport}?RCONPort=${rconport}?Port=${port} -automanagedmods\"" #### LinuxGSM Settings #### diff --git a/lgsm/config-default/config-lgsm/csgoserver/_default.cfg b/lgsm/config-default/config-lgsm/csgoserver/_default.cfg index c19233e41..7cbdb93f6 100644 --- a/lgsm/config-default/config-lgsm/csgoserver/_default.cfg +++ b/lgsm/config-default/config-lgsm/csgoserver/_default.cfg @@ -10,14 +10,14 @@ ## Server Start Settings | https://github.com/GameServerManagers/LinuxGSM/wiki/Start-Parameters # https://developer.valvesoftware.com/wiki/Counter-Strike:_Global_Offensive_Dedicated_Servers#Starting_the_Server -# [Game Modes] gametype gamemode -# Arms Race 1 0 -# Classic Casual 0 0 -# Classic Competitive 0 1 +# [Game Modes] gametype gamemode mapgroup (you can mix these across Game Modes, but use only one) +# Arms Race 1 0 mg_armsrace +# Classic Casual 0 0 mg_casualsigma, mg_casualdelta +# Classic Competitive 0 1 mg_active, mg_reserves, mg_hostage, mg_de_dust2 # Custom 3 0 -# Deathmatch 1 2 -# Demolition 1 1 -# Wingman 0 2 +# Deathmatch 1 2 mg_deathmatch +# Demolition 1 1 mg_demolition +# Wingman 0 2 gametype="0" gamemode="0" mapgroup="mg_active" diff --git a/lgsm/config-default/config-lgsm/hwserver/_default.cfg b/lgsm/config-default/config-lgsm/hwserver/_default.cfg index fa4742cbb..a2335e8ec 100644 --- a/lgsm/config-default/config-lgsm/hwserver/_default.cfg +++ b/lgsm/config-default/config-lgsm/hwserver/_default.cfg @@ -9,7 +9,7 @@ #### Server Settings #### ## Server Start Settings | https://github.com/GameServerManagers/LinuxGSM/wiki/Start-Parameters -servername="Hurtworld LinuxGSM Server" +servername="LinuxGSM Server" ip="0.0.0.0" port="12871" queryport="12881" diff --git a/lgsm/config-default/config-lgsm/inssserver/_default.cfg b/lgsm/config-default/config-lgsm/inssserver/_default.cfg new file mode 100644 index 000000000..6681a49a6 --- /dev/null +++ b/lgsm/config-default/config-lgsm/inssserver/_default.cfg @@ -0,0 +1,134 @@ +################################## +######## Default Settings ######## +################################## +# DO NOT EDIT WILL BE OVERWRITTEN! +# Copy settings from here and use them in either +# common.cfg - applies settings to every instance +# [instance].cfg - applies settings to a specific instance + +#### Server Settings #### + +## Server Start Settings | https://github.com/GameServerManagers/LinuxGSM/wiki/Start-Parameters + +ip="0.0.0.0" +port="27102" +queryport="27131" +servername="LinuxGSM Server" +serverpassword="" +defaultmap="Oilfield" +defaultscenario="Scenario_Oilfield_Push_Security" +maxplayers="28" + +## Server Start Command | https://github.com/GameServerManagers/LinuxGSM/wiki/Start-Parameters#additional-parameters +fn_parms(){ +parms="${defaultmap}?Scenario=${defaultscenario}?MaxPlayers=${maxplayers}?Port=${port}?QueryPort=${queryport} -password=${serverpassword} -hostname='${servername}' -log" +} + +#### LinuxGSM Settings #### + +## Notification Alerts +# (on|off) + +# More info | https://github.com/GameServerManagers/LinuxGSM/wiki/Alerts#more-info +postalert="off" +postdays="7" +posttarget="https://hastebin.com" + +# Discord Alerts | https://github.com/GameServerManagers/LinuxGSM/wiki/Discord +discordalert="off" +discordwebhook="webhook" + +# Email Alerts | https://github.com/GameServerManagers/LinuxGSM/wiki/Email +emailalert="off" +email="email@example.com" +emailfrom="" + +# IFTTT Alerts | https://github.com/GameServerManagers/LinuxGSM/wiki/IFTTT +iftttalert="off" +ifttttoken="accesstoken" +iftttevent="linuxgsm_alert" + +# Mailgun Email Alerts | https://github.com/GameServerManagers/LinuxGSM/wiki/mailgun +mailgunalert="off" +mailguntoken="accesstoken" +mailgundomain="example.com" +mailgunemailfrom="alert@example.com" +mailgunemail="email@myemail.com" + +# Pushbullet Alerts | https://github.com/GameServerManagers/LinuxGSM/wiki/Pushbullet +pushbulletalert="off" +pushbullettoken="accesstoken" +channeltag="" + +# Pushover Alerts | https://github.com/GameServerManagers/LinuxGSM/wiki/Pushover +pushoveralert="off" +pushovertoken="accesstoken" + +# Telegram Alerts | https://github.com/GameServerManagers/LinuxGSM/wiki/Telegram +# You can add a custom cURL string eg proxy (useful in Russia) or else in "curlcustomstring". +# like a "--socks5 ipaddr:port" for socks5 proxy see more in "curl --help", if you not need +# any custom string in curl - simple ignore this parameter. +telegramalert="off" +telegramtoken="accesstoken" +telegramchatid="" +curlcustomstring="" + +## Updating | https://github.com/GameServerManagers/LinuxGSM/wiki/Update +updateonstart="off" + +## Backup | https://github.com/GameServerManagers/LinuxGSM/wiki/Backup +maxbackups="4" +maxbackupdays="30" +stoponbackup="on" + +## Logging | https://github.com/GameServerManagers/LinuxGSM/wiki/Logging +consolelogging="on" +logdays="7" + +#### LinuxGSM Advanced Settings #### + +# ANSI Colors +ansi="on" + +## SteamCMD Settings +# Server appid +appid="581330" +# Steam App Branch Select +# Allows to opt into the various Steam app branches. Default branch is "". +# Example: "-beta latest_experimental" +branch="" + +## LinuxGSM Server Details +# Do not edit +gamename="Insurgency: Sandstorm" +engine="unreal4" + +#### Directories #### +# Edit with care + +## Server Specific Directories +systemdir="${serverfiles}/Insurgency" +executabledir="${systemdir}/Binaries/Linux" +executable="./InsurgencyServer-Linux-Shipping" +servercfg="Game.ini" +servercfgdefault="Game.ini" +servercfgdir="${systemdir}/Saved/Config/LinuxServer" +servercfgfullpath="${servercfgdir}/${servercfg}" + +## Backup Directory +backupdir="${lgsmdir}/backup" + +## Logging Directories +logdir="${rootdir}/log" +gamelogdir="${systemdir}/Saved/Logs" +lgsmlogdir="${logdir}/script" +consolelogdir="${logdir}/console" +gamelog="${gamelogdir}/${servicename}-game.log" +lgsmlog="${lgsmlogdir}/${servicename}-script.log" +consolelog="${consolelogdir}/${servicename}-console.log" +alertlog="${lgsmlogdir}/${servicename}-alert.log" +postdetailslog="${lgsmlogdir}/${servicename}-postdetails.log" + +## Logs Naming +lgsmlogdate="${lgsmlogdir}/${servicename}-script-$(date '+%Y-%m-%d-%H:%M:%S').log" +consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%Y-%m-%d-%H:%M:%S').log" diff --git a/lgsm/config-default/config-lgsm/ns2cserver/_default.cfg b/lgsm/config-default/config-lgsm/ns2cserver/_default.cfg index b3b4b1caa..dfb4844a1 100644 --- a/lgsm/config-default/config-lgsm/ns2cserver/_default.cfg +++ b/lgsm/config-default/config-lgsm/ns2cserver/_default.cfg @@ -13,7 +13,7 @@ ip="0.0.0.0" port="27015" defaultmap="co_core" maxplayers="24" -servername="NS2C Server" +servername="LinuxGSM Server" webadminuser="admin" webadminpass="admin" webadminport="8080" diff --git a/lgsm/config-default/config-lgsm/ns2server/_default.cfg b/lgsm/config-default/config-lgsm/ns2server/_default.cfg index b842091a5..fea5a772c 100644 --- a/lgsm/config-default/config-lgsm/ns2server/_default.cfg +++ b/lgsm/config-default/config-lgsm/ns2server/_default.cfg @@ -17,7 +17,7 @@ ip="0.0.0.0" port="27015" defaultmap="ns2_summit" maxplayers="24" -servername="NS2 Server" +servername="LinuxGSM Server" webadminuser="admin" webadminpass="admin" webadminport="8080" diff --git a/lgsm/config-default/config-lgsm/pstbsserver/_default.cfg b/lgsm/config-default/config-lgsm/pstbsserver/_default.cfg index 8f472ce6b..7d1fb6b97 100644 --- a/lgsm/config-default/config-lgsm/pstbsserver/_default.cfg +++ b/lgsm/config-default/config-lgsm/pstbsserver/_default.cfg @@ -14,7 +14,7 @@ ip="0.0.0.0" randommap="ALWAYS" port="10027" queryport="10037" -#servername="LinuxGSM server" +#servername="LinuxGSM Server" # If your server is not meeting the minimal server requirement, do not host the server for 80 players, decrease that number. maxplayers="40" numreservedslots="2" diff --git a/lgsm/data/serverlist.csv b/lgsm/data/serverlist.csv index 12bb0532c..2a55c4122 100644 --- a/lgsm/data/serverlist.csv +++ b/lgsm/data/serverlist.csv @@ -36,6 +36,7 @@ hldms,hldmsserver,Half-Life Deathmatch: Source hldm,hldmserver,Half-Life: Deathmatch hw,hwserver,Hurtworld ins,insserver,Insurgency +inss,inssserver,Insurgency: Sandstorm jc2,jc2server,Just Cause 2 jc3,jc3server,Just Cause 3 kf,kfserver,Killing Floor diff --git a/lgsm/functions/alert_discord.sh b/lgsm/functions/alert_discord.sh index 4818f8721..12382706f 100644 --- a/lgsm/functions/alert_discord.sh +++ b/lgsm/functions/alert_discord.sh @@ -1,49 +1,47 @@ #!/bin/bash # LinuxGSM alert_discord.sh function # Author: Daniel Gibbs -# Contributor: faflfama +# Contributor: faflfama, diamondburned # Website: https://linuxgsm.com # Description: Sends Discord alert. +if ! command -v jq > /dev/null; then + fn_print_fail_nl "Sending Discord alert: jq is missing." + fn_script_log_fatal "Sending Discord alert: jq is missing." +fi + +escaped_servername="$(echo -n "${servername}" | jq -sRr "@json")" +escaped_alertbody="$(echo -n "${alertbody}" | jq -sRr "@json")" + json=$(cat <${alertsubject} ${alertemoji}\n\nMessage\n${alertbody}\n\nGame\n${gamename}\n\nServer name\n${servername}\n\nHostname\n${HOSTNAME}\n\nServer IP\n${ip}:${port}\n\nMore info\n${alerturl}", + "text": "${alertemoji} ${alertsubject} ${alertemoji}\n\nMessage\n${alertbody}\n\nGame\n${gamename}\n\nServer name\n${servername}\n\nHostname\n${HOSTNAME}\n\nServer IP\n${extip:-$ip}:${port}\n\nMore info\n${alerturl}", "disable_web_page_preview": "yes", EOF ) diff --git a/lgsm/functions/check_ip.sh b/lgsm/functions/check_ip.sh index ba2d472c1..992fd0e93 100644 --- a/lgsm/functions/check_ip.sh +++ b/lgsm/functions/check_ip.sh @@ -21,7 +21,7 @@ if [ "${gamename}" != "TeamSpeak 3" ]&&[ "${gamename}" != "Mumble" ]&&[ "${travi # IP is not set to specific IP if [ "${ip}" == "0.0.0.0" ]||[ "${ip}" == "" ]; then fn_print_dots "Check IP" - sleep 0.5 + sleep 0.2 # Multiple interfaces if [ "${getipwc}" -ge "2" ]; then if [ "${function_selfname}" == "command_details.sh" ]; then @@ -29,7 +29,7 @@ if [ "${gamename}" != "TeamSpeak 3" ]&&[ "${gamename}" != "Mumble" ]&&[ "${travi else fn_print_fail "Check IP: Multiple IP addresses found." fi - sleep 0.5 + sleep 0.2 echo -en "\n" # IP is set within game config if [ "${ipsetinconfig}" == "1" ]; then @@ -85,7 +85,7 @@ if [ "${gamename}" != "TeamSpeak 3" ]&&[ "${gamename}" != "Mumble" ]&&[ "${travi else fn_print_info_nl "Check IP: ${getip}" fn_script_log_info "IP automatically set as: ${getip}" - sleep 0.5 + sleep 0.2 ip="${getip}" fi fi diff --git a/lgsm/functions/check_status.sh b/lgsm/functions/check_status.sh index 61d1d030d..529dcbf5b 100644 --- a/lgsm/functions/check_status.sh +++ b/lgsm/functions/check_status.sh @@ -12,7 +12,7 @@ if [ "${shortname}" == "ts3" ]; then # 1: Server is running # 0: Server seems to have died # 0: No server running (ts3server.pid is missing) - status=$("${executabledir}/ts3server_startscript.sh" status servercfgfullpathfile=${servercfgfullpath}) + status=$("${executabledir}/ts3server_startscript.sh" status servercfgfullpathfile="${servercfgfullpath}") if [ "${status}" == "Server is running" ]; then status=1 else diff --git a/lgsm/functions/command_debug.sh b/lgsm/functions/command_debug.sh index 453c42894..23cb49f4b 100644 --- a/lgsm/functions/command_debug.sh +++ b/lgsm/functions/command_debug.sh @@ -56,7 +56,6 @@ if [ "${multiple_ip}" == "1" ]; then else echo -e "${blue}Server IP:\t${default}${ip}:${port}" fi -echo -e "${blue}Server IP:\t${default}${ip}:${port}" # External server ip if [ -n "${extip}" ]; then if [ "${ip}" != "${extip}" ]; then diff --git a/lgsm/functions/command_dev_query_raw.sh b/lgsm/functions/command_dev_query_raw.sh index 2dc39b951..c16d517aa 100644 --- a/lgsm/functions/command_dev_query_raw.sh +++ b/lgsm/functions/command_dev_query_raw.sh @@ -29,7 +29,7 @@ elif [ "${gamename}" == "Killing Floor 2" ]; then fi query_gamedig.sh -echo "gamedig --type \"${gamedigengine}\" --host \"${ip}\" --query_port \"${queryport}\"|jq" +echo "${gamedigcmd}" echo"" echo "${gamedigraw}" | jq echo"" diff --git a/lgsm/functions/command_donate.sh b/lgsm/functions/command_donate.sh new file mode 100644 index 000000000..a277b87b6 --- /dev/null +++ b/lgsm/functions/command_donate.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# LinuxGSM command_donate.sh function +# Author: Daniel Gibbs +# Website: https://linuxgsm.com +# Description: Shows ways to donate + +echo -e "" +echo -e "${lightyellow}Support LinuxGSM${default}" +echo -e "=================================" +echo -e "" +echo -e "Been using LinuxGSM?" +echo -e "Consider donating to support development." +echo -e "" +echo -e "* ${blue}Patreon:${default} https://linuxgsm.com/patreon" +echo -e "* ${blue}PayPal:${default} https://linuxgsm.com/paypal" +echo -e "* ${blue}Flattr:${default} https://linuxgsm.com/flattr" +echo -e "" +echo -e "LinuxGSM has been going since 2012" \ No newline at end of file diff --git a/lgsm/functions/core_functions.sh b/lgsm/functions/core_functions.sh index f4b27fdd1..416835504 100644 --- a/lgsm/functions/core_functions.sh +++ b/lgsm/functions/core_functions.sh @@ -51,6 +51,12 @@ fn_fetch_function # Commands + +command_backup.sh(){ +functionfile="${FUNCNAME}" +fn_fetch_function +} + command_console.sh(){ functionfile="${FUNCNAME}" fn_fetch_function @@ -61,22 +67,22 @@ functionfile="${FUNCNAME}" fn_fetch_function } -command_postdetails.sh(){ +command_details.sh(){ functionfile="${FUNCNAME}" fn_fetch_function } -command_details.sh(){ +command_donate.sh(){ functionfile="${FUNCNAME}" fn_fetch_function } -command_test_alert.sh(){ +command_postdetails.sh(){ functionfile="${FUNCNAME}" fn_fetch_function } -command_backup.sh(){ +command_test_alert.sh(){ functionfile="${FUNCNAME}" fn_fetch_function } diff --git a/lgsm/functions/core_getopt.sh b/lgsm/functions/core_getopt.sh index 07b5e71f9..4766fabe9 100644 --- a/lgsm/functions/core_getopt.sh +++ b/lgsm/functions/core_getopt.sh @@ -20,6 +20,7 @@ cmd_backup=( "b;backup" "command_backup.sh" "Create backup archives of the serve cmd_update_linuxgsm=( "ul;update-lgsm;uf;update-functions" "command_update_linuxgsm.sh" "Check and apply any LinuxGSM updates." ) cmd_test_alert=( "ta;test-alert" "command_test_alert.sh" "Send a test alert." ) cmd_monitor=( "m;monitor" "command_monitor.sh" "Check server status and restart if crashed." ) +cmd_donate=( "do;donate" "command_donate.sh" "Donation options." ) # Console servers only cmd_console=( "c;console" "command_console.sh" "Access server console." ) cmd_debug=( "d;debug" "command_debug.sh" "Start server directly in your terminal." ) @@ -51,6 +52,7 @@ cmd_dev_detect_ldd=( "dl;detect-ldd" "command_dev_detect_ldd.sh" "Detect require cmd_dev_query_raw=( "qr;query-raw" "command_dev_query_raw.sh" "The raw output of gamedig and gsquery." ) cmd_dev_clear_functions=( "cf;clear-functions" "command_dev_clear_functions.sh" "Delete the contents of the functions dir." ) + ### Set specific opt here ### currentopt=( "${cmd_start[@]}" "${cmd_stop[@]}" "${cmd_restart[@]}" "${cmd_monitor[@]}" "${cmd_test_alert[@]}" "${cmd_details[@]}" "${cmd_postdetails[@]}" ) @@ -136,6 +138,9 @@ if [ -f ".dev-debug" ]; then currentopt+=( "${cmd_dev_detect_deps[@]}" "${cmd_dev_detect_glibc[@]}" "${cmd_dev_detect_ldd[@]}" "${cmd_dev_query_raw[@]}" "${cmd_dev_clear_functions[@]}" ) fi +## Donate +currentopt+=( "${cmd_donate[@]}" ) + ### Build list of available commands optcommands=() index="0" @@ -150,7 +155,7 @@ done fn_opt_usage(){ echo "Usage: $0 [option]" echo -e "" - echo "${gamename} - Linux Game Server Manager - Version ${version}" + echo "LinuxGSM - ${gamename} - Version ${version}" echo "https://linuxgsm.com/${gameservername}" echo -e "" echo -e "${lightyellow}Commands${default}" diff --git a/lgsm/functions/info_config.sh b/lgsm/functions/info_config.sh index 97ba4eb1d..632dc44ea 100644 --- a/lgsm/functions/info_config.sh +++ b/lgsm/functions/info_config.sh @@ -297,6 +297,29 @@ fn_info_config_factorio(){ fi } +fn_info_config_inss(){ + if [ ! -f "${servercfgfullpath}" ]; then + rconenabled="${unavailable}" + rconpassword="${unavailable}" + rconport="${zero}" + maxplayers="${zero}" + port="${zero}" + queryport="${zero}" + queryenabled="${unavailable}" + rconport="${zero}" + gamemode="${unavailable}" + gameworld="${unavailable}" + else + rconenabled=$(grep "bEnabled" "${servercfgfullpath}" | sed -e 's/^[ \t]*//g' -e '/^#/d' -e 's/bEnabled//g' | tr -d '=\";,:' | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//') + rconpassword=$(grep "Password" "${servercfgfullpath}" | sed -e 's/^[ \t]*//g' -e '/^#/d' -e 's/Password//g' | tr -d '=\";,:' | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//') + rconport=$(grep "ListenPort" "${servercfgfullpath}" | tr -cd '[:digit:]') + + # Not Set + rconenabled=${rconenabled:-"NOT SET"} + rconpassword=${rconpassword:-"NOT SET"} + rconport=${rconport:-"0"} + fi +} fn_info_config_minecraft(){ if [ ! -f "${servercfgfullpath}" ]; then servername="${unavailable}" @@ -364,7 +387,7 @@ fn_info_config_pstbs(){ servername=${servername:-"NOT SET"} serverpassword=${serverpassword:-"NOT SET"} maxplayers=${maxplayers:-"0"} - numreservedslots=${maxplayers:-"0"} + numreservedslots=${numreservedslots:-"0"} } fn_info_config_projectcars(){ @@ -1121,6 +1144,9 @@ elif [ "${shortname}" == "eco" ]; then # Factorio elif [ "${gamename}" == "Factorio" ]; then fn_info_config_factorio +# Insurgency: Sandstorm +elif [ "${shortname}" == "inss" ]; then + fn_info_config_inss # Just Cause 2 elif [ "${gamename}" == "Just Cause 2" ]; then fn_info_config_justcause2 diff --git a/lgsm/functions/info_distro.sh b/lgsm/functions/info_distro.sh index 8716bb9f8..d9b6bcef6 100644 --- a/lgsm/functions/info_distro.sh +++ b/lgsm/functions/info_distro.sh @@ -91,33 +91,65 @@ load=$(uptime|awk -F 'load average: ' '{ print $2 }') ## Memory information -# Issue #2005 - Kernel 3.14+ contains MemAvailable which should be used. All others will be calculated - -# get the raw KB values of these fields -physmemtotalkb=$(grep MemTotal /proc/meminfo | awk '{print $2}') -physmemfreekb=$(grep ^MemFree /proc/meminfo | awk '{print $2}') -physmembufferskb=$(grep ^Buffers /proc/meminfo | awk '{print $2}') -physmemcachedkb=$(grep ^Cached /proc/meminfo | awk '{print $2}') -physmemreclaimablekb=$(grep ^SReclaimable /proc/meminfo | awk '{print $2}') - -# check if MemAvailable Exists -if grep -q ^MemAvailable /proc/meminfo; then - physmemactualfreekb=$(grep ^MemAvailable /proc/meminfo | awk '{print $2}') -else - physmemactualfreekb=$((${physmemfreekb}+${physmembufferskb}+${physmemcachedkb})) -fi +## Memory information # Available RAM and swap. -physmemtotalmb=$((${physmemtotalkb}/1024)) -physmemtotal=$(numfmt --to=iec --from=iec --suffix=B "${physmemtotalkb}K") -physmemfree=$(numfmt --to=iec --from=iec --suffix=B "${physmemactualfreekb}K") -physmemused=$(numfmt --to=iec --from=iec --suffix=B "$((${physmemtotalkb}-${physmemfreekb}-${physmembufferskb}-${physmemcachedkb}-${physmemreclaimablekb}))K") -physmemavailable=$(numfmt --to=iec --from=iec --suffix=B "${physmemactualfreekb}K") -physmemcached=$(numfmt --to=iec --from=iec --suffix=B "$((${physmemcachedkb}+${physmemreclaimablekb}))K") -swaptotal=$(numfmt --to=iec --from=iec --suffix=B "$(grep ^SwapTotal /proc/meminfo | awk '{print $2}')K") -swapfree=$(numfmt --to=iec --from=iec --suffix=B "$(grep ^SwapFree /proc/meminfo | awk '{print $2}')K") -swapused=$(numfmt --to=iec --from=iec --suffix=B "$(($(grep ^SwapTotal /proc/meminfo | awk '{print $2}')-$(grep ^SwapFree /proc/meminfo | awk '{print $2}')))K") +# Newer distros can use numfmt to give more accurate results +if [ -n "$(command -v numfmt 2>/dev/null)" ]; then + # Issue #2005 - Kernel 3.14+ contains MemAvailable which should be used. All others will be calculated + + # get the raw KB values of these fields + physmemtotalkb=$(grep MemTotal /proc/meminfo | awk '{print $2}') + physmemfreekb=$(grep ^MemFree /proc/meminfo | awk '{print $2}') + physmembufferskb=$(grep ^Buffers /proc/meminfo | awk '{print $2}') + physmemcachedkb=$(grep ^Cached /proc/meminfo | awk '{print $2}') + physmemreclaimablekb=$(grep ^SReclaimable /proc/meminfo | awk '{print $2}') + + # check if MemAvailable Exists + if grep -q ^MemAvailable /proc/meminfo; then + physmemactualfreekb=$(grep ^MemAvailable /proc/meminfo | awk '{print $2}') + else + physmemactualfreekb=$((${physmemfreekb}+${physmembufferskb}+${physmemcachedkb})) + fi + + # Available RAM and swap. + physmemtotalmb=$((${physmemtotalkb}/1024)) + physmemtotal=$(numfmt --to=iec --from=iec --suffix=B "${physmemtotalkb}K") + physmemfree=$(numfmt --to=iec --from=iec --suffix=B "${physmemactualfreekb}K") + physmemused=$(numfmt --to=iec --from=iec --suffix=B "$((${physmemtotalkb}-${physmemfreekb}-${physmembufferskb}-${physmemcachedkb}-${physmemreclaimablekb}))K") + physmemavailable=$(numfmt --to=iec --from=iec --suffix=B "${physmemactualfreekb}K") + physmemcached=$(numfmt --to=iec --from=iec --suffix=B "$((${physmemcachedkb}+${physmemreclaimablekb}))K") + + swaptotal=$(numfmt --to=iec --from=iec --suffix=B "$(grep ^SwapTotal /proc/meminfo | awk '{print $2}')K") + swapfree=$(numfmt --to=iec --from=iec --suffix=B "$(grep ^SwapFree /proc/meminfo | awk '{print $2}')K") + swapused=$(numfmt --to=iec --from=iec --suffix=B "$(($(grep ^SwapTotal /proc/meminfo | awk '{print $2}')-$(grep ^SwapFree /proc/meminfo | awk '{print $2}')))K") +else +# Older distros will need to use free. + # Older versions of free do not support -h option. + if [ "$(free -h > /dev/null 2>&1; echo $?)" -ne "0" ]; then + humanreadable="-m" + else + humanreadable="-h" + fi + physmemtotalmb=$(free -m | awk '/Mem:/ {print $2}') + physmemtotal=$(free ${humanreadable} | awk '/Mem:/ {print $2}') + physmemfree=$(free ${humanreadable} | awk '/Mem:/ {print $4}') + physmemused=$(free ${humanreadable} | awk '/Mem:/ {print $3}') + + oldfree=$(free ${humanreadable} | awk '/cache:/') + if [ -n "${oldfree}" ]; then + physmemavailable="n/a" + physmemcached="n/a" + else + physmemavailable=$(free ${humanreadable} | awk '/Mem:/ {print $7}') + physmemcached=$(free ${humanreadable} | awk '/Mem:/ {print $6}') + fi + + swaptotal=$(free ${humanreadable} | awk '/Swap:/ {print $2}') + swapused=$(free ${humanreadable} | awk '/Swap:/ {print $3}') + swapfree=$(free ${humanreadable} | awk '/Swap:/ {print $4}') +fi ### Disk information @@ -174,10 +206,14 @@ fi # External IP address if [ -z "${extip}" ]; then - extip=$(${curlpath} -m 3 ifconfig.co > "${tmpdir}/extip.txt" 2>/dev/null) - if [ $? -ne 0 ]; then + extip=$(${curlpath} -4 -m 3 ifconfig.co 2>/dev/null) + exitcode=$? + # Should ifconfig.co return an error will use last known IP + if [ ${exitcode} -eq 0 ]; then + echo "${extip}" > "${tmpdir}/extip.txt" + else if [ -f "${tmpdir}/extip.txt" ]; then - echo "${tmpdir}/extip.txt" + extip=$(cat ${tmpdir}/extip.txt) else echo "x.x.x.x" fi diff --git a/lgsm/functions/info_glibc.sh b/lgsm/functions/info_glibc.sh index f3597cbf8..015c1e169 100644 --- a/lgsm/functions/info_glibc.sh +++ b/lgsm/functions/info_glibc.sh @@ -12,9 +12,6 @@ if [ "${gamename}" == "ARK: Survival Evolved" ]; then elif [ "${gamename}" == "Ballistic Overkill" ]; then glibcrequired="2.15" glibcfix="yes" -elif [ "${gamename}" == "Battalion 1944" ]; then - glibcrequired="2.17" - glibcfix="no" elif [ "${gamename}" == "Base Defense" ]; then glibcrequired="2.14" glibcfix="no" @@ -78,6 +75,9 @@ elif [ "${gamename}" == "Insurgency" ]; then elif [ "${shortname}" == "kf2" ]; then glibcrequired="2.17" glibcfix="no" +elif [ "${shortname}" == "tu" ]; then + glibcrequired="2.15" + glibcfix="no" elif [ "${gamename}" == "Mumble" ]; then glibcrequired="NOT REQUIRED" glibcfix="no" @@ -129,31 +129,34 @@ elif [ "${gamename}" == "Just Cause 2" ]; then elif [ "${gamename}" == "Just Cause 3" ]; then glibcrequired="2.17" glibcfix="no" -elif [ "${engine}" == "dontstarve" ]; then +elif [ "${gamename}" == "Natural Selection 2" ]; then + glibcrequired="2.17" + glibcfix="no" +elif [ "${gamename}" == "NS2: Combat" ]; then glibcrequired="2.15" + glibcfix="yes" +elif [ "${gamename}" == "TeamSpeak 3" ]; then + glibcrequired="NOT REQUIRED" glibcfix="no" -elif [ "${engine}" == "lwjgl2" ]; then +elif [ "${gamename}" == "Mumble" ]; then glibcrequired="NOT REQUIRED" glibcfix="no" -elif [ "${engine}" == "projectzomboid" ]; then - glibcrequired="2.15" +elif [ "${engine}" == "refractor" ]; then + glibcrequired="2.0" glibcfix="no" -elif [ "${engine}" == "realvirtuality" ]; then - glibcrequired="2.13" - glibcfix="yes" -elif [ "${engine}" == "seriousengine35" ]; then - glibcrequired="2.13" - glibcfix="yes" -elif [ "${engine}" == "source" ]; then - glibcrequired="2.3.6" +elif [ "${gamename}" == "Wolfenstein: Enemy Territory" ]; then + glibcrequired="2.2.4" glibcfix="no" -elif [ "${engine}" == "goldsource" ]; then - glibcrequired="2.3.4" +elif [ "${gamename}" == "ET: Legacy" ]; then + glibcrequired="2.7" glibcfix="no" -elif [ "${gamename}" == "Natural Selection 2" ]; then - glibcrequired="2.17" +elif [ "${gamename}" == "Wurm Unlimited" ]; then + glibcrequired="2.14" glibcfix="no" -elif [ "${gamename}" == "NS2: Combat" ]; then +elif [ "${gamename}" == "Multi Theft Auto" ]; then + glibcrequired="2.7" + glibcfix="no" +elif [ "${gamename}" == "Zombie Panic! Source" ]; then glibcrequired="2.15" glibcfix="yes" elif [ "${engine}" == "starbound" ]; then @@ -175,35 +178,32 @@ elif [ "${engine}" == "unreal3" ]; then glibcrequired="2.3.2" glibcfix="no" elif [ "${engine}" == "unreal4" ]; then - glibcrequired="2.14" + glibcrequired="2.17" glibcfix="no" elif [ "${engine}" == "unity3d" ]; then glibcrequired="2.15" glibcfix="no" -elif [ "${gamename}" == "TeamSpeak 3" ]; then - glibcrequired="NOT REQUIRED" +elif [ "${engine}" == "dontstarve" ]; then + glibcrequired="2.15" glibcfix="no" -elif [ "${gamename}" == "Mumble" ]; then +elif [ "${engine}" == "lwjgl2" ]; then glibcrequired="NOT REQUIRED" glibcfix="no" -elif [ "${engine}" == "refractor" ]; then - glibcrequired="2.0" - glibcfix="no" -elif [ "${gamename}" == "Wolfenstein: Enemy Territory" ]; then - glibcrequired="2.2.4" - glibcfix="no" -elif [ "${gamename}" == "ET: Legacy" ]; then - glibcrequired="2.7" - glibcfix="no" -elif [ "${gamename}" == "Wurm Unlimited" ]; then - glibcrequired="2.14" - glibcfix="no" -elif [ "${gamename}" == "Multi Theft Auto" ]; then - glibcrequired="2.7" - glibcfix="no" -elif [ "${gamename}" == "Zombie Panic! Source" ]; then +elif [ "${engine}" == "projectzomboid" ]; then glibcrequired="2.15" + glibcfix="no" +elif [ "${engine}" == "realvirtuality" ]; then + glibcrequired="2.13" glibcfix="yes" +elif [ "${engine}" == "seriousengine35" ]; then + glibcrequired="2.13" + glibcfix="yes" +elif [ "${engine}" == "source" ]; then + glibcrequired="2.3.6" + glibcfix="no" +elif [ "${engine}" == "goldsource" ]; then + glibcrequired="2.3.4" + glibcfix="no" else glibcrequired="UNKNOWN" glibcfix="no" diff --git a/lgsm/functions/info_messages.sh b/lgsm/functions/info_messages.sh index 996559796..03ebcda49 100644 --- a/lgsm/functions/info_messages.sh +++ b/lgsm/functions/info_messages.sh @@ -225,11 +225,25 @@ fn_info_message_gameserver(){ echo -e "${blue}Current Map:\t${default}${gdmap}" fi + if [ -n "${defaultscenario}" ]; then + # Current Scenario + if [ -n "${gdgamemode}" ]; then + echo -e "${blue}Current Scenario:\t${default}${gdgamemode}" + fi + else + echo -e "${blue}Current Game Mode:\t${default}${gdgamemode}" + fi + # Default Map if [ -n "${defaultmap}" ]; then echo -e "${blue}Default Map:\t${default}${defaultmap}" fi + # Default Scenario + if [ -n "${defaultscenario}" ]; then + echo -e "${blue}Default Scenario:\t${default}${defaultscenario}" + fi + # Game type if [ -n "${gametype}" ]; then echo -e "${blue}Game type:\t${default}${gametype}" @@ -444,6 +458,10 @@ fn_info_message_commandlineparms(){ echo -e "${lightgreen}Command-line Parameters${default}" fn_info_message_password_strip fn_messages_separator + if [ "${serverpassword}" == "NOT SET" ]; then + unset serverpassword + fi + fn_parms echo -e "${executable} ${parms}" } @@ -677,6 +695,17 @@ fn_info_message_hurtworld(){ } | column -s $'\t' -t } +fn_info_message_inss(){ + echo -e "netstat -atunp | grep Insurgency" + echo -e "" + { + echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL" + echo -e "> Game\tINBOUND\t${port}\tudp" + echo -e "> Query\tINBOUND\t${queryport}\tudp" + echo -e "> RCON\tINBOUND\t${rconport}\ttcp" + } | column -s $'\t' -t +} + fn_info_message_justcause2(){ echo -e "netstat -atunp | grep Jcmp-Server" echo -e "" @@ -1144,6 +1173,8 @@ fn_info_message_select_engine(){ fn_info_message_factorio elif [ "${gamename}" == "Hurtworld" ]; then fn_info_message_hurtworld + elif [ "${shortname}" == "inss" ]; then + fn_info_message_inss elif [ "${gamename}" == "Just Cause 2" ]; then fn_info_message_justcause2 elif [ "${gamename}" == "Just Cause 3" ]; then diff --git a/lgsm/functions/info_parms.sh b/lgsm/functions/info_parms.sh index f1ecf21f7..2345f5864 100644 --- a/lgsm/functions/info_parms.sh +++ b/lgsm/functions/info_parms.sh @@ -31,6 +31,7 @@ fn_info_parms_cod(){ defaultmap=${defaultmap:-"NOT SET"} maxplayers=${maxplayers:-"0"} port=${port:-"0"} + queryport=${port:-"0"} } fn_info_parms_dst(){ @@ -45,13 +46,22 @@ fn_info_parms_eco(){ queryport=${webadminport} } - fn_info_parms_factorio(){ port=${port:-"0"} rconport=${rconport:-"0"} rconpassword=${rconpassword:-"NOT SET"} } +fn_info_parms_inss(){ + port=${port:-"0"} + queryport=${queryport:-"0"} + servername=${servername:-"NOT SET"} + serverpassword=${serverpassword:-"NOT SET"} + defaultmap=${defaultmap:-"NOT SET"} + defaultscenario=${defaultscenario:-"NOT SET"} + maxplayers=${maxplayers:-"0"} +} + fn_info_parms_hurtworld(){ servername=${servername:-"NOT SET"} port=${port:-"0"} @@ -158,6 +168,8 @@ elif [ "${gamename}" == "Eco" ]; then # Factorio elif [ "${gamename}" == "Factorio" ]; then fn_info_parms_factorio +elif [ "${shortname}" == "inss" ]; then + fn_info_parms_inss elif [ "${shortname}" == "kf2" ]; then fn_info_parms_kf2 # Project Zomboid diff --git a/lgsm/functions/install_header.sh b/lgsm/functions/install_header.sh index cae416547..40c2845fc 100644 --- a/lgsm/functions/install_header.sh +++ b/lgsm/functions/install_header.sh @@ -10,9 +10,9 @@ local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" clear echo "=================================" -echo "${gamename}" -echo "Linux Game Server Manager" +echo "LinuxGSM - ${gamename}" echo "by Daniel Gibbs" -echo "Contributors: http://goo.gl/qLmitD" -echo "https://linuxgsm.com" +echo "Website: https://linuxgsm.com" +echo "Contributors: https://linuxgsm.com/contrib" +echo "Donate: https://linuxgsm.com/donate" echo "=================================" diff --git a/lgsm/functions/install_server_files.sh b/lgsm/functions/install_server_files.sh index a67045747..e3930843b 100644 --- a/lgsm/functions/install_server_files.sh +++ b/lgsm/functions/install_server_files.sh @@ -72,7 +72,7 @@ fn_install_server_files_steamcmd(){ fi if [ "${counter}" -ge "7" ]; then - echo "Removing $(find ${serverfiles} -type d -print0 | grep -Ez '[^/]{30}$')" + echo "Removing $(find "${serverfiles}" -type d -print0 | grep -Ez '[^/]{30}$')" find "${serverfiles}" -type d -print0 | grep -Ez '[^/]{30}$' | xargs -0 rm -rf fi if [ "${counter}" -ge "9" ]; then diff --git a/lgsm/functions/mods_list.sh b/lgsm/functions/mods_list.sh index dcc2fbecf..eb1e2f8bf 100644 --- a/lgsm/functions/mods_list.sh +++ b/lgsm/functions/mods_list.sh @@ -61,8 +61,8 @@ mod_info_metamod=( MOD "metamod" "MetaMod" "${metamodurl}" "${metamodlatestfile} mod_info_sourcemod=( MOD "sourcemod" "SourceMod" "${sourcemodurl}" "${sourcemodlatestfile}" "0" "LowercaseOff" "${systemdir}" "cfg;addons/sourcemod/configs;" "source;" "GAMES" "NOTGAMES" "http://www.sourcemod.net" "Admin Features (requires MetaMod)" ) # CS:GO Mods -mod_info_gokz=( MOD "gokz" "GOKZ" "https://bitbucket.org/kztimerglobalteam/gokz/downloads/GOKZ-latest.zip" "gokz-latest.zip" "0" "LowercaseOff" "${systemdir}" "cfg;addons/sourcemod/configs;" "source;" "Counter Strike: Global Offensive" "NOTGAMES" "https://bitbucket.org/kztimerglobalteam/gokz/src/master/" "Implements the KZ game mode (requires SourceMod and MetaMod)") -mod_info_ttt=( MOD "ttt" "Trouble in Terrorist Town" "https://csgottt.com/downloads/ttt-latest-dev-${sourcemodmversion}.zip" "ttt-latest.zip" "0" "LowercaseOff" "${systemdir}" "cfg;addons/sourcemod/configs;" "source;" "Counter Strike: Global Offensive" "NOTGAMES" "https://github.com/Bara/TroubleinTerroristTown" "Implements the TTT game mode (requires SourceMod and MetaMod)") +mod_info_gokz=( MOD "gokz" "GOKZ" "https://bitbucket.org/kztimerglobalteam/gokz/downloads/GOKZ-latest.zip" "gokz-latest.zip" "0" "LowercaseOff" "${systemdir}" "cfg;addons/sourcemod/configs;" "ENGINES" "Counter Strike: Global Offensive" "NOTGAMES" "https://bitbucket.org/kztimerglobalteam/gokz/src/master/" "Implements the KZ game mode (requires SourceMod and MetaMod)") +mod_info_ttt=( MOD "ttt" "Trouble in Terrorist Town" "https://csgottt.com/downloads/ttt-latest-dev-${sourcemodmversion}.zip" "ttt-latest.zip" "0" "LowercaseOff" "${systemdir}" "cfg;addons/sourcemod/configs;" "ENGINES" "Counter Strike: Global Offensive" "NOTGAMES" "https://github.com/Bara/TroubleinTerroristTown" "Implements the TTT game mode (requires SourceMod and MetaMod)") # Garry's Mod Addons mod_info_ulib=( MOD "ulib" "ULib" "https://codeload.github.com/TeamUlysses/ulib/zip/master" "ulib-master.zip" "0" "LowercaseOff" "${systemdir}/addons" "OVERWRITE" "ENGINES" "Garry's Mod;" "NOTGAMES" "http://ulyssesmod.net" "Complete Framework" ) diff --git a/lgsm/functions/query_gamedig.sh b/lgsm/functions/query_gamedig.sh index b8cad6159..1bdce107a 100644 --- a/lgsm/functions/query_gamedig.sh +++ b/lgsm/functions/query_gamedig.sh @@ -73,10 +73,18 @@ if [ "$(command -v gamedig 2>/dev/null)" ]&&[ "$(command -v jq 2>/dev/null)" ]; # will bypass query if server offline check_status.sh if [ "${status}" != "0" ]; then - # checks if query is working 0 = pass - querystatus=$(gamedig --type "${gamedigengine}" --host "${ip}" --query_port "${queryport}" | jq '.error|length') - # raw output + # checks if query is working null = pass + gamedigcmd=$(echo "gamedig --type \"${gamedigengine}\" --host \"${ip}\" --query_port \"${queryport}\"|jq") gamedigraw=$(gamedig --type "${gamedigengine}" --host "${ip}" --query_port "${queryport}") + querystatus=$(echo "${gamedigraw}" | jq '.error|length') + + if [ "${querystatus}" != "null" ]; then + gamedigcmd=$(echo "gamedig --type \"${gamedigengine}\" --host \"${ip}\" --port \"${queryport}\"|jq") + gamedigraw=$(gamedig --type "${gamedigengine}" --host "${ip}" --port "${queryport}") + querystatus=$(echo "${gamedigraw}" | jq '.error|length') + + fi + # server name gdname=$(echo "${gamedigraw}" | jq -re '.name') @@ -102,6 +110,12 @@ if [ "$(command -v gamedig 2>/dev/null)" ]&&[ "$(command -v jq 2>/dev/null)" ]; gdmap= fi + # current gamemode + gdgamemode=$(echo "${gamedigraw}" | jq -re '.raw.rules.GameMode_s') + if [ "${gdgamemode}" == "null" ]; then + gdgamemode= + fi + # numbots gdbots=$(echo "${gamedigraw}" | jq -re '.raw.numbots') if [ "${gdbots}" == "null" ]; then diff --git a/lgsm/functions/update_steamcmd.sh b/lgsm/functions/update_steamcmd.sh index 15fb0277f..480624f7b 100644 --- a/lgsm/functions/update_steamcmd.sh +++ b/lgsm/functions/update_steamcmd.sh @@ -157,7 +157,7 @@ fn_update_steamcmd_check(){ fi # Set branch for updateinfo - IFS=' ' read -ra branchsplits <<< ${branch} + IFS=' ' read -ra branchsplits <<< "${branch}" if [ "${#branchsplits[@]}" -gt 1 ]; then branchname="${branchsplits[1]}" else