From e40365d45a21ecbf305037c8245b92d3d6dfb80f Mon Sep 17 00:00:00 2001 From: Alexander Hurd Date: Wed, 12 Oct 2016 02:43:20 -0400 Subject: [PATCH 1/5] adding San Andreas Multiplayer --- SanAndreasMultiplayer/sampserver | 143 +++++++++++++++++++++++++ lgsm/functions/command_install.sh | 2 +- lgsm/functions/install_server_files.sh | 2 + 3 files changed, 146 insertions(+), 1 deletion(-) create mode 100644 SanAndreasMultiplayer/sampserver diff --git a/SanAndreasMultiplayer/sampserver b/SanAndreasMultiplayer/sampserver new file mode 100644 index 000000000..99753333f --- /dev/null +++ b/SanAndreasMultiplayer/sampserver @@ -0,0 +1,143 @@ +#!/bin/bash +# San Andreas Multiplayer +# 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="210516" + +#### Variables #### + +# Notification Alerts +# (on|off) + +# Email +emailalert="off" +email="email@example.com" +#emailfrom="email@example.com" + +# Pushbullet +# https://www.pushbullet.com/#settings +pushbulletalert="off" +pushbullettoken="accesstoken" + +# Start Variables +ip="0.0.0.0" + +fn_parms(){ +parms=" " +} + +#### Advanced Variables #### + +# Github Branch Select +# Allows for the use of different function files +# from a different repo and/or branch. +githubuser="dgibbs64" +githubrepo="linuxgsm" +githubbranch="samp" + +# Server Details +servicename="samp-server" +gamename="San Andreas Multiplayer" +engine="RenderWare" + +# 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" +systemdir="${filesdir}" +executabledir="${systemdir}" +executable="samp03svr" +servercfg="server.cfg" +servercfgdir="${systemdir}" +servercfgfullpath="${servercfgdir}/${servercfg}" +backupdir="${rootdir}/backups" + +# Logging +logdays="7" +gamelogdir="${filesdir}/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/command_install.sh b/lgsm/functions/command_install.sh index bcfe36fd2..75c44bc67 100644 --- a/lgsm/functions/command_install.sh +++ b/lgsm/functions/command_install.sh @@ -18,7 +18,7 @@ check_deps.sh if [ "${gamename}" == "Unreal Tournament 2004" ]; then install_server_files.sh install_ut2k4_key.sh -elif [ "${gamename}" == "Unreal Tournament 3" ]||[ "${gamename}" == "Battlefield: 1942" ]||[ "${gamename}" == "Enemy Territory" ]||[ "${gamename}" == "Unreal Tournament 99" ]||[ "${gamename}" == "Unreal Tournament" ]||[ "${gamename}" == "TeamSpeak 3" ]||[ "${gamename}" == "Minecraft" ]||[ "${gamename}" == "Mumble" ]; then +elif [ "${gamename}" == "Unreal Tournament 3" ]||[ "${gamename}" == "Battlefield: 1942" ]||[ "${gamename}" == "Enemy Territory" ]||[ "${gamename}" == "Unreal Tournament 99" ]||[ "${gamename}" == "Unreal Tournament" ]||[ "${gamename}" == "TeamSpeak 3" ]||[ "${gamename}" == "Minecraft" ]||[ "${gamename}" == "Mumble" ]|[ "${gamename}" == "San Andreas Multiplayer" ]; then installer=1 install_server_files.sh elif [ -n "${appid}" ]; then diff --git a/lgsm/functions/install_server_files.sh b/lgsm/functions/install_server_files.sh index e1b140bb8..4961deb85 100644 --- a/lgsm/functions/install_server_files.sh +++ b/lgsm/functions/install_server_files.sh @@ -23,6 +23,8 @@ fn_install_server_files(){ fileurl="http://files.gameservermanagers.com/UnrealTournament/UnrealTournament-Server-XAN-3045522-Linux.zip"; filedir="${tmpdir}"; filename="UnrealTournament-Server-XAN-3045522-Linux.zip"; executecmd="noexecute" run="norun"; force="noforce"; md5="553fed5645a9fc623e92563049bf79f6" elif [ "${gamename}" == "GoldenEye: Source" ]; then fileurl="http://files.gameservermanagers.com/GoldenEyeSource/GoldenEye_Source_v5.0.1_full_server_linux.tar.bz2"; filedir="${tmpdir}"; filename="GoldenEye_Source_v5.0.1_server_full_Linux.tar.bz2"; executecmd="noexecute" run="norun"; force="noforce"; md5="ea227a150300abe346e757380325f84c" + elif [ "${gamename}" == "San Andresas Multiplayer" ]; then + fileurl="http://files.sa-mp.com/samp037svr_R2-1.tar.gz"; filedir="${tmpdir}"; filename="samp037svr_R2-1.tar.gz"; executecmd="noexecute" run="norun"; force="noforce"; md5="93705e165550c97484678236749198a4" fi fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${executecmd}" "${run}" "${force}" "${md5}" fn_dl_extract "${filedir}" "${filename}" "${filesdir}" From c547ecfe1e57a3e20a870763c1182c98196ecb4e Mon Sep 17 00:00:00 2001 From: Alexander Hurd Date: Wed, 12 Oct 2016 02:46:37 -0400 Subject: [PATCH 2/5] name fix --- lgsm/functions/install_server_files.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lgsm/functions/install_server_files.sh b/lgsm/functions/install_server_files.sh index 4961deb85..1df3af632 100644 --- a/lgsm/functions/install_server_files.sh +++ b/lgsm/functions/install_server_files.sh @@ -23,7 +23,7 @@ fn_install_server_files(){ fileurl="http://files.gameservermanagers.com/UnrealTournament/UnrealTournament-Server-XAN-3045522-Linux.zip"; filedir="${tmpdir}"; filename="UnrealTournament-Server-XAN-3045522-Linux.zip"; executecmd="noexecute" run="norun"; force="noforce"; md5="553fed5645a9fc623e92563049bf79f6" elif [ "${gamename}" == "GoldenEye: Source" ]; then fileurl="http://files.gameservermanagers.com/GoldenEyeSource/GoldenEye_Source_v5.0.1_full_server_linux.tar.bz2"; filedir="${tmpdir}"; filename="GoldenEye_Source_v5.0.1_server_full_Linux.tar.bz2"; executecmd="noexecute" run="norun"; force="noforce"; md5="ea227a150300abe346e757380325f84c" - elif [ "${gamename}" == "San Andresas Multiplayer" ]; then + elif [ "${gamename}" == "San Andreas Multiplayer" ]; then fileurl="http://files.sa-mp.com/samp037svr_R2-1.tar.gz"; filedir="${tmpdir}"; filename="samp037svr_R2-1.tar.gz"; executecmd="noexecute" run="norun"; force="noforce"; md5="93705e165550c97484678236749198a4" fi fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${executecmd}" "${run}" "${force}" "${md5}" From 25d8e2f1187f33d602f094a0811623bdd0d43485 Mon Sep 17 00:00:00 2001 From: Alexander Hurd Date: Wed, 12 Oct 2016 03:13:08 -0400 Subject: [PATCH 3/5] adding config --- SanAndreasMultiplayer/cfg/lgsm-default.cfg | 17 +++++++++++++++++ lgsm/functions/install_config.sh | 6 ++++++ 2 files changed, 23 insertions(+) create mode 100644 SanAndreasMultiplayer/cfg/lgsm-default.cfg diff --git a/SanAndreasMultiplayer/cfg/lgsm-default.cfg b/SanAndreasMultiplayer/cfg/lgsm-default.cfg new file mode 100644 index 000000000..558aeecbb --- /dev/null +++ b/SanAndreasMultiplayer/cfg/lgsm-default.cfg @@ -0,0 +1,17 @@ +echo Executing Server Config... +lanmode 0 +rcon_password +maxplayers 50 +port 7777 +hostname +gamemode0 grandlarc 1 +filterscripts base gl_actions gl_property gl_realtime +announce 0 +query 1 +weburl www.sa-mp.com +maxnpc 0 +onfoot_rate 40 +incar_rate 40 +weapon_rate 40 +stream_distance 300.0 +stream_rate 1000 diff --git a/lgsm/functions/install_config.sh b/lgsm/functions/install_config.sh index 5a856f8e6..e829d153b 100644 --- a/lgsm/functions/install_config.sh +++ b/lgsm/functions/install_config.sh @@ -401,6 +401,12 @@ elif [ "${gamename}" == "Rust" ]; then wget -N /dev/null ${githuburl}/Rust/cfg/lgsm-default.cfg 2>&1 | grep -F HTTP | cut -c45- | uniq sleep 1 fn_defaultconfig +elif [ "${gamename}" == "San Andreas Multiplayer" ]; then + echo -e "downloading server.cfg...\c" + wget -N /dev/null ${githuburl}/SanAndreasMultiplayer/cfg/lgsm-default.cfg 2>&1 | grep -F HTTP | cut -c45- | uniq + sleep 1 + fn_defaultconfig + fn_userinputconfig elif [ "${gamename}" == "Sven Co-op" ]; then echo -e "downloading lgsm-default.cfg...\c" wget -N /dev/null ${githuburl}/SvenCoop/cfg/lgsm-default.cfg 2>&1 | grep -F HTTP | cut -c45- | uniq From 8d060955aa03e6d220b99394e76f51e6cd21ce78 Mon Sep 17 00:00:00 2001 From: Alexander Hurd Date: Wed, 12 Oct 2016 03:39:26 -0400 Subject: [PATCH 4/5] config fix --- SanAndreasMultiplayer/cfg/lgsm-default.cfg | 4 ++-- SanAndreasMultiplayer/sampserver | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) mode change 100644 => 100755 SanAndreasMultiplayer/sampserver diff --git a/SanAndreasMultiplayer/cfg/lgsm-default.cfg b/SanAndreasMultiplayer/cfg/lgsm-default.cfg index 558aeecbb..1a1922b60 100644 --- a/SanAndreasMultiplayer/cfg/lgsm-default.cfg +++ b/SanAndreasMultiplayer/cfg/lgsm-default.cfg @@ -1,9 +1,9 @@ echo Executing Server Config... lanmode 0 -rcon_password +rcon_password "" maxplayers 50 port 7777 -hostname +hostname "" gamemode0 grandlarc 1 filterscripts base gl_actions gl_property gl_realtime announce 0 diff --git a/SanAndreasMultiplayer/sampserver b/SanAndreasMultiplayer/sampserver old mode 100644 new mode 100755 index 99753333f..219b9e173 --- a/SanAndreasMultiplayer/sampserver +++ b/SanAndreasMultiplayer/sampserver @@ -28,7 +28,9 @@ pushbullettoken="accesstoken" # Start Variables ip="0.0.0.0" +port="7777" +#no params - check server.cfg fn_parms(){ parms=" " } @@ -57,11 +59,12 @@ libdir="${lgsmdir}/lib" tmpdir="${lgsmdir}/tmp" filesdir="${rootdir}/serverfiles" systemdir="${filesdir}" -executabledir="${systemdir}" -executable="samp03svr" +executabledir="${systemdir}/samp03" +executable="./samp03svr" servercfg="server.cfg" -servercfgdir="${systemdir}" +servercfgdir="${systemdir}/samp03" servercfgfullpath="${servercfgdir}/${servercfg}" +servercfgdefault="${servercfgdir}/lgsm-default.cfg" backupdir="${rootdir}/backups" # Logging From 2762ce780ae4aa6d237ec360a6e8c610f4cfa5ad Mon Sep 17 00:00:00 2001 From: Alexander Hurd Date: Wed, 12 Oct 2016 03:43:13 -0400 Subject: [PATCH 5/5] ready for merge --- SanAndreasMultiplayer/sampserver | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/SanAndreasMultiplayer/sampserver b/SanAndreasMultiplayer/sampserver index 219b9e173..6fa9a9165 100755 --- a/SanAndreasMultiplayer/sampserver +++ b/SanAndreasMultiplayer/sampserver @@ -30,7 +30,6 @@ pushbullettoken="accesstoken" ip="0.0.0.0" port="7777" -#no params - check server.cfg fn_parms(){ parms=" " } @@ -42,7 +41,7 @@ parms=" " # from a different repo and/or branch. githubuser="dgibbs64" githubrepo="linuxgsm" -githubbranch="samp" +githubbranch="master" # Server Details servicename="samp-server"