diff --git a/ProjectCars/pcserver b/ProjectCars/pcserver new file mode 100755 index 000000000..b05dec06f --- /dev/null +++ b/ProjectCars/pcserver @@ -0,0 +1,193 @@ +#!/bin/bash +# Project: Game Server Managers - LinuxGSM +# Author: Daniel Gibbs +# License: MIT License, Copyright (c) 2017 Daniel Gibbs +# Purpose: Project Cars | Server Management Script +# Contributors: https://github.com/GameServerManagers/LinuxGSM/graphs/contributors +# Documentation: https://github.com/GameServerManagers/LinuxGSM/wiki +# Website: https://gameservermanagers.com + +# Debugging +if [ -f ".dev-debug" ]; then + exec 5>dev-debug.log + BASH_XTRACEFD="5" + set -x +fi + +version="170219" + +########################## +######## Settings ######## +########################## + +#### Server Settings #### + +# Notification Alerts +## Server Start Command | https://github.com/GameServerManagers/LinuxGSM/wiki/Start-Parameters#additional-parameters +fn_parms(){ +parms="--config ${servercfg}" +} + +#### LinuxGSM Settings #### + +## Notification Alerts +# (on|off) +# Email Alerts | https://github.com/GameServerManagers/LinuxGSM/wiki/Email +emailalert="off" +email="email@example.com" +emailfrom="" + +# Pushbullet Alerts | https://github.com/GameServerManagers/LinuxGSM/wiki/Pushbullet +pushbulletalert="off" +pushbullettoken="accesstoken" +channeltag="" + +## 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 #### + +## SteamCMD Settings +# Server appid +appid="332670" +# Steam App Branch Select +# Allows to opt into the various Steam app branches. Default branch is "". +# Example: "-beta latest_experimental" +branch="" + +## Github Branch Select +# Allows for the use of different function files +# from a different repo and/or branch. +githubuser="GameServerManagers" +githubrepo="LinuxGSM" +githubbranch="master" + +## LinuxGSM Server Details +# Do not edit +gamename="Project Cars" +engine="madness" + +## Service Name | https://github.com/GameServerManagers/LinuxGSM/wiki/Multiple-Servers +servicename="pc-server" + +#### Directories #### +# Edit with care + +## Work Directories +rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))" +selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +lockselfname=".${servicename}.lock" +lgsmdir="${rootdir}/lgsm" +functionsdir="${lgsmdir}/functions" +libdir="${lgsmdir}/lib" +tmpdir="${lgsmdir}/tmp" +filesdir="${rootdir}/serverfiles" + +## Server Specific Directories +systemdir="${filesdir}" +executabledir="${filesdir}" +executable="./DedicatedServerCmd" +servercfg="${servicename}.cfg" +servercfgdefault="server.cfg" +servercfgdir="${systemdir}" +servercfgfullpath="${servercfgdir}/${servercfg}" + +## Backup Directory +backupdir="${rootdir}/backups" + +## Logging Directories +gamelogdir="${systemdir}/logs" +scriptlogdir="${rootdir}/log/script" +consolelogdir="${rootdir}/log/console" +scriptlog="${scriptlogdir}/${servicename}-script.log" +consolelog="${consolelogdir}/${servicename}-console.log" +emaillog="${scriptlogdir}/${servicename}-email.log" + +## Logs Naming +scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%Y-%m-%d-%H:%M:%S').log" +consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%Y-%m-%d-%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 +} + +# Prevent from running this script as root. +if [ "$(whoami)" = "root" ]; then + if [ ! -f "${functionsdir}/core_functions.sh" ]||[ ! -f "${functionsdir}/check_root.sh" ]||[ ! -f "${functionsdir}/core_messages.sh" ]||[ ! -f "${functionsdir}/core_exit.sh" ]; then + echo "[ FAIL ] Do NOT run this script as root!" + exit 1 + else + core_functions.sh + check_root.sh + fi +fi + +core_dl.sh +core_functions.sh +getopt=$1 +core_getopt.sh \ No newline at end of file diff --git a/lgsm/functions/command_details.sh b/lgsm/functions/command_details.sh index debf5442d..106eb0041 100644 --- a/lgsm/functions/command_details.sh +++ b/lgsm/functions/command_details.sh @@ -315,7 +315,7 @@ fn_details_ports(){ parmslocation="${red}UNKNOWN${default}" # engines/games that require editing in the config file - local ports_edit_array=( "avalanche" "Ballistic Overkill" "dontstarve" "idtech2" "idtech3" "idtech3_ql" "lwjgl2" "projectzomboid" "quake" "refractor" "realvirtuality" "renderware" "seriousengine35" "teeworlds" "terraria" "unreal" "unreal2" "unreal3" "TeamSpeak 3" "Mumble" "7 Days To Die" ) + local ports_edit_array=( "avalanche" "Ballistic Overkill" "dontstarve" "idtech2" "idtech3" "idtech3_ql" "lwjgl2" "Project Cars" "projectzomboid" "quake" "refractor" "realvirtuality" "renderware" "seriousengine35" "teeworlds" "terraria" "unreal" "unreal2" "unreal3" "TeamSpeak 3" "Mumble" "7 Days To Die" ) for port_edit in "${ports_edit_array[@]}" do if [ "${engine}" == "${port_edit}" ]||[ "${gamename}" == "${port_edit}" ]; then @@ -487,6 +487,17 @@ fn_details_mumble(){ } | column -s $'\t' -t } +fn_details_projectcars(){ + echo -e "netstat -atunp | grep DedicatedS" + echo -e "" + { + echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL" + echo -e "> Game\tINBOUND\t${port}\tudp" + echo -e "> Query\tINBOUND\t${queryport}\tudp" + echo -e "> Steam\tINBOUND\t${queryport}\tudp" + } | column -s $'\t' -t +} + fn_details_projectzomboid(){ echo -e "netstat -atunp | grep java" echo -e "" @@ -840,6 +851,8 @@ fn_display_details() { fn_details_factorio elif [ "${gamename}" == "Hurtworld" ]; then fn_details_hurtworld + elif [ "${gamename}" == "Project Cars" ]; then + fn_details_projectcars elif [ "${gamename}" == "QuakeWorld" ]; then fn_details_quake elif [ "${gamename}" == "Quake 2" ]; then diff --git a/lgsm/functions/info_config.sh b/lgsm/functions/info_config.sh index cb17e09d5..a179efbb4 100644 --- a/lgsm/functions/info_config.sh +++ b/lgsm/functions/info_config.sh @@ -49,6 +49,29 @@ fn_info_config_ark(){ fi } +fn_info_config_ballistic_overkill(){ + if [ ! -f "${servercfgfullpath}" ]; then + servername="${unavailable}" + serverpassword="${unavailable}" + port="${zero}" + queryport="${zero}" + maxplayers="${unavailable}" + else + servername=$(grep "ServerName=" "${servercfgfullpath}" | sed -e 's/^[ \t]*//g' -e '/^#/d' -e 's/ServerName//g' | tr -d '=\";,:' | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//') + serverpassword=$(grep "Password=" "${servercfgfullpath}" | sed -e 's/^[ \t]*//g' -e '/^#/d' -e 's/Password//g' | tr -d '=\";,:' | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//') + port=$(grep "ServerPort=" "${servercfgfullpath}" | tr -cd '[:digit:]') + queryport=$((port + 1)) + maxplayers=$(grep "MaxPlayers=" "${servercfgfullpath}" | tr -cd '[:digit:]') + + # Not Set + servername=${servername:-"NOT SET"} + serverpassword=${serverpassword:-"NOT SET"} + port=${port:-"0"} + queryport=${queryport:-"0"} + maxplayers=${maxplayers:-"NOT SET"} + fi +} + fn_info_config_bf1942(){ if [ ! -f "${servercfgfullpath}" ]; then servername="${unavailable}" @@ -227,6 +250,32 @@ fn_info_config_minecraft(){ fi } +fn_info_config_projectcars(){ + if [ ! -f "${servercfgfullpath}" ]; then + servername="${unavailable}" + serverpassword="${unavailable}" + maxplayers="${zero}" + port="${zero}" + queryport="${zero}" + steamport="${zero}" + else + servername=$(grep "name" "${servercfgfullpath}" | sed -e 's/^[ \t]*//g' -e '/^\//d' -e 's/name//g' | tr -d '=\";,:' | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//') + serverpassword=$(grep "password " "${servercfgfullpath}" | sed -e 's/^[ \t]*//g' -e '/^\//d' -e 's/password//g' | tr -d '=\";,:' | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//') + maxplayers=$(grep "MaxPlayers" "${servercfgfullpath}" | grep -v "//" | tr -cd '[:digit:]') + port=$(grep "hostPort" "${servercfgfullpath}" | grep -v "//" | tr -cd '[:digit:]') + queryport=$(grep "queryPort" "${servercfgfullpath}" | grep -v "//" | tr -cd '[:digit:]') + steamport=$(grep "steamPort" "${servercfgfullpath}" | grep -v "//" | tr -cd '[:digit:]') + + # Not Set + servername=${servername:-"NOT SET"} + serverpassword=${serverpassword:-"NOT SET"} + maxplayers=${maxplayers:-"NOT SET"} + port=${port:-"NOT SET"} + queryport=${queryport:-"NOT SET"} + steamport=${steamport:-"NOT SET"} + fi +} + fn_info_config_projectzomboid(){ if [ ! -f "${servercfgfullpath}" ]; then servername="${unavailable}" @@ -315,33 +364,6 @@ fn_info_config_quakelive(){ fi } -fn_info_config_wolfensteinenemyterritory(){ - if [ ! -f "${servercfgfullpath}" ]; then - rconpassword="${unavailable}" - servername="${unavailable}" - serverpassword="${unavailable}" - maxplayers="${zero}" - port="${zero}" - else - port=$(grep "set net_port" "${servercfgfullpath}" | grep -v "//" | tr -cd '[:digit:]') - rconpassword=$(grep "set zmq_rcon_password" "${servercfgfullpath}" | sed -e 's/^[ \t]*//g' -e '/^\//d' -e 's/set zmq_rcon_password //g' | tr -d '=\";,:' | sed -e 's/^[ \t]*//g' -e '/^\//d' | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//') - servername=$(grep "set sv_hostname" "${servercfgfullpath}" | sed -e 's/^[ \t]*//g' -e '/^\//d' -e 's/set sv_hostname //g' | tr -d '=\";,:' | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//') - serverpassword=$(grep "set g_password" "${servercfgfullpath}" | sed -e 's/^[ \t]*//g' -e '/^\//d' -e 's/set g_password //g' | tr -d '=\";,:' | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//') - maxplayers=$(grep "set sv_maxclients" "${servercfgfullpath}" | grep -v "//" | tr -cd '[:digit:]') - - ip=$(grep "set net_ip" "${servercfgfullpath}" | sed -e 's/^[ \t]*//g' -e '/^\//d' -e 's/set net_ip//g' | tr -d '=\";,:' | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//') - ipsetinconfig=1 - ipinconfigvar="set net_ip" - - # Not Set - rconpassword=${rconpassword:-"NOT SET"} - servername=${servername:-"NOT SET"} - serverpassword=${serverpassword:-"NOT SET"} - maxplayers=${maxplayers:-"0"} - port=${port:-"27960"} - fi -} - fn_info_config_realvirtuality(){ if [ ! -f "${servercfgfullpath}" ]; then servername="${unavailable}" @@ -568,29 +590,6 @@ fn_info_config_unreal(){ fi } -fn_info_config_ballistic_overkill(){ - if [ ! -f "${servercfgfullpath}" ]; then - servername="${unavailable}" - serverpassword="${unavailable}" - port="${zero}" - queryport="${zero}" - maxplayers="${unavailable}" - else - servername=$(grep "ServerName=" "${servercfgfullpath}" | sed -e 's/^[ \t]*//g' -e '/^#/d' -e 's/ServerName//g' | tr -d '=\";,:' | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//') - serverpassword=$(grep "Password=" "${servercfgfullpath}" | sed -e 's/^[ \t]*//g' -e '/^#/d' -e 's/Password//g' | tr -d '=\";,:' | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//') - port=$(grep "ServerPort=" "${servercfgfullpath}" | tr -cd '[:digit:]') - queryport=$((port + 1)) - maxplayers=$(grep "MaxPlayers=" "${servercfgfullpath}" | tr -cd '[:digit:]') - - # Not Set - servername=${servername:-"NOT SET"} - serverpassword=${serverpassword:-"NOT SET"} - port=${port:-"0"} - queryport=${queryport:-"0"} - maxplayers=${maxplayers:-"NOT SET"} - fi -} - fn_info_config_sdtd(){ if [ ! -f "${servercfgfullpath}" ]; then servername="${unavailable}" @@ -677,6 +676,33 @@ fn_info_config_mta(){ fi } +fn_info_config_wolfensteinenemyterritory(){ + if [ ! -f "${servercfgfullpath}" ]; then + rconpassword="${unavailable}" + servername="${unavailable}" + serverpassword="${unavailable}" + maxplayers="${zero}" + port="${zero}" + else + port=$(grep "set net_port" "${servercfgfullpath}" | grep -v "//" | tr -cd '[:digit:]') + rconpassword=$(grep "set zmq_rcon_password" "${servercfgfullpath}" | sed -e 's/^[ \t]*//g' -e '/^\//d' -e 's/set zmq_rcon_password //g' | tr -d '=\";,:' | sed -e 's/^[ \t]*//g' -e '/^\//d' | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//') + servername=$(grep "set sv_hostname" "${servercfgfullpath}" | sed -e 's/^[ \t]*//g' -e '/^\//d' -e 's/set sv_hostname //g' | tr -d '=\";,:' | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//') + serverpassword=$(grep "set g_password" "${servercfgfullpath}" | sed -e 's/^[ \t]*//g' -e '/^\//d' -e 's/set g_password //g' | tr -d '=\";,:' | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//') + maxplayers=$(grep "set sv_maxclients" "${servercfgfullpath}" | grep -v "//" | tr -cd '[:digit:]') + + ip=$(grep "set net_ip" "${servercfgfullpath}" | sed -e 's/^[ \t]*//g' -e '/^\//d' -e 's/set net_ip//g' | tr -d '=\";,:' | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//') + ipsetinconfig=1 + ipinconfigvar="set net_ip" + + # Not Set + rconpassword=${rconpassword:-"NOT SET"} + servername=${servername:-"NOT SET"} + serverpassword=${serverpassword:-"NOT SET"} + maxplayers=${maxplayers:-"0"} + port=${port:-"27960"} + fi +} + # Just Cause 2 if [ "${engine}" == "avalanche" ]; then fn_info_config_avalanche @@ -719,6 +745,9 @@ elif [ "${gamename}" == "Quake Live" ]; then # Minecraft elif [ "${engine}" == "lwjgl2" ]; then fn_info_config_minecraft +# Project Cars +elif [ "${gamename}" == "Project Cars" ]; then + fn_info_config_projectcars # Project Zomboid elif [ "${engine}" == "projectzomboid" ]; then fn_info_config_projectzomboid diff --git a/lgsm/functions/info_glibc.sh b/lgsm/functions/info_glibc.sh index ad505eb0e..97a395962 100644 --- a/lgsm/functions/info_glibc.sh +++ b/lgsm/functions/info_glibc.sh @@ -65,6 +65,9 @@ elif [ "${gamename}" == "Mumble" ]; then elif [ "${gamename}" == "No More Room in Hell" ]; then glibcrequired="2.15" glibcfix="yes" +elif [ "${gamename}" == "Project Cars" ]; then + glibcrequired="2.4" + glibcfix="no" elif [ "${gamename}" == "Quake 2" ]; then glibcrequired="NOT REQUIRED" glibcfix="no" diff --git a/lgsm/functions/install_config.sh b/lgsm/functions/install_config.sh index 529f87038..249e5291e 100644 --- a/lgsm/functions/install_config.sh +++ b/lgsm/functions/install_config.sh @@ -395,6 +395,12 @@ elif [ "${gamename}" == "Project Zomboid" ]; then fn_fetch_default_config fn_default_config_remote fn_set_config_vars +elif [ "${gamename}" == "Project Cars" ]; then + gamedirname="ProjectCars" + array_configs+=( server.cfg ) + fn_fetch_default_config + fn_default_config_remote + fn_set_config_vars elif [ "${gamename}" == "Quake 2" ]; then gamedirname="Quake2" array_configs+=( server.cfg )