4 changed files with 280 additions and 200 deletions
@ -1,198 +0,0 @@ |
|||
#!/bin/bash |
|||
# Project: Game Server Managers - LinuxGSM |
|||
# Author: Daniel Gibbs |
|||
# License: MIT License, Copyright (c) 2016 Daniel Gibbs |
|||
# Purpose: Jedi Knight II: Jedi Outcast | 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="161125" |
|||
|
|||
########################## |
|||
######## Settings ######## |
|||
########################## |
|||
|
|||
#### Server Settings #### |
|||
|
|||
## SteamCMD Login | https://github.com/GameServerManagers/LinuxGSM/wiki/SteamCMD#steamcmd-login |
|||
steamuser="username" |
|||
steampass="password" |
|||
|
|||
## Server Start Settings | https://github.com/GameServerManagers/LinuxGSM/wiki/Start-Parameters |
|||
defaultmap="ffa_bespin" |
|||
ip="0.0.0.0" |
|||
port="27960" |
|||
|
|||
## Server Start Command | https://github.com/GameServerManagers/LinuxGSM/wiki/Start-Parameters#additional-parameters |
|||
fn_parms(){ |
|||
parms="+set sv_punkbuster 0 +set fs_basepath ${filesdir} +set dedicated 1 +set com_hunkMegs 32 +set net_ip ${ip} +set net_port ${port} +exec ${servercfg} +map ${defaultmap}" |
|||
} |
|||
|
|||
#### LinuxGSM Settings #### |
|||
|
|||
## Notification Alerts |
|||
# (on|off) |
|||
# Email Alerts | https://github.com/GameServerManagers/LinuxGSM/wiki/Email |
|||
emailalert="off" |
|||
email="[email protected]" |
|||
emailfrom="" |
|||
|
|||
# Pushbullet Alerts | https://github.com/GameServerManagers/LinuxGSM/wiki/Pushbullet |
|||
pushbulletalert="off" |
|||
pushbullettoken="accesstoken" |
|||
channeltag="" |
|||
|
|||
## 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="6030" |
|||
# 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="nateberkopec" |
|||
githubrepo="LinuxGSM" |
|||
githubbranch="jk2" |
|||
|
|||
## LinuxGSM Server Details |
|||
# Do not edit |
|||
gamename="Jedi Knight II: Jedi Outcast" |
|||
engine="idtech3" |
|||
|
|||
## Service Name | https://github.com/GameServerManagers/LinuxGSM/wiki/Multiple-Servers |
|||
servicename="jk2ded" |
|||
|
|||
#### 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}/baseq3" |
|||
executabledir="${filesdir}" |
|||
executable="./q3ded" |
|||
servercfg="${servicename}.cfg" |
|||
servercfgdefault="server.cfg" |
|||
servercfgdir="${systemdir}" |
|||
servercfgfullpath="${servercfgdir}/${servercfg}" |
|||
|
|||
## Backup Directory |
|||
backupdir="${rootdir}/backups" |
|||
|
|||
## Logging Directories |
|||
gamelogdir="${filesdir}/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 |
@ -0,0 +1,138 @@ |
|||
################################## |
|||
######## 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://docs.linuxgsm.com/configuration/start-parameters |
|||
ip="0.0.0.0" |
|||
port="27960" |
|||
defaultmap="ffa_bespin" |
|||
|
|||
## Server Start Command | https://docs.linuxgsm.com/configuration/start-parameters#additional-parameters |
|||
fn_parms(){ |
|||
parms="+set sv_punkbuster 0 +set fs_basepath ${filesdir} +set dedicated 1 +set com_hunkMegs 32 +set net_ip ${ip} +set net_port ${port} +exec ${servercfg} +map ${defaultmap}" |
|||
} |
|||
|
|||
#### LinuxGSM Settings #### |
|||
|
|||
## Notification Alerts |
|||
# (on|off) |
|||
|
|||
# Display IP | https://docs.linuxgsm.com/alerts#display-ip |
|||
displayip="" |
|||
|
|||
# More info | https://docs.linuxgsm.com/alerts#more-info |
|||
postalert="off" |
|||
postdays="7" |
|||
posttarget="https://hastebin.com" |
|||
|
|||
# Discord Alerts | https://docs.linuxgsm.com/alerts/discord |
|||
discordalert="off" |
|||
discordwebhook="webhook" |
|||
|
|||
# Email Alerts | https://docs.linuxgsm.com/alerts/email |
|||
emailalert="off" |
|||
email="[email protected]" |
|||
emailfrom="" |
|||
|
|||
# IFTTT Alerts | https://docs.linuxgsm.com/alerts/ifttt |
|||
iftttalert="off" |
|||
ifttttoken="accesstoken" |
|||
iftttevent="linuxgsm_alert" |
|||
|
|||
# Mailgun Email Alerts | https://docs.linuxgsm.com/alerts/mailgun |
|||
mailgunalert="off" |
|||
mailguntoken="accesstoken" |
|||
mailgundomain="example.com" |
|||
mailgunemailfrom="[email protected]" |
|||
mailgunemail="[email protected]" |
|||
|
|||
# Pushbullet Alerts | https://docs.linuxgsm.com/alerts/pushbullet |
|||
pushbulletalert="off" |
|||
pushbullettoken="accesstoken" |
|||
channeltag="" |
|||
|
|||
# Pushover Alerts | https://docs.linuxgsm.com/alerts/pushover |
|||
pushoveralert="off" |
|||
pushovertoken="accesstoken" |
|||
|
|||
# Telegram Alerts | https://docs.linuxgsm.com/alerts/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://docs.linuxgsm.com/commands/update |
|||
updateonstart="off" |
|||
|
|||
## Backup | https://docs.linuxgsm.com/commands/backup |
|||
maxbackups="4" |
|||
maxbackupdays="30" |
|||
stoponbackup="on" |
|||
|
|||
## Logging | https://docs.linuxgsm.com/features/logging |
|||
consolelogging="on" |
|||
logdays="7" |
|||
|
|||
## Monitor | https://docs.linuxgsm.com/commands/monitor |
|||
# Query delay time |
|||
querydelay="1" |
|||
|
|||
#### LinuxGSM Advanced Settings #### |
|||
|
|||
# ANSI Colors |
|||
ansi="on" |
|||
|
|||
# Message Display Time |
|||
sleeptime="0.5" |
|||
|
|||
## SteamCMD Settings |
|||
# Server appid |
|||
appid="6030" |
|||
# SteamCMD Branch | https://docs.linuxgsm.com/steamcmd/branch |
|||
branch="" |
|||
# Master Server | https://docs.linuxgsm.com/steamcmd/steam-master-server |
|||
steammaster="true" |
|||
|
|||
## LinuxGSM Server Details |
|||
# Do not edit |
|||
gamename="Jedi Knight II: Jedi Outcast" |
|||
engine="idtech3" |
|||
glibc="" |
|||
|
|||
#### Directories #### |
|||
# Edit with care |
|||
|
|||
## Server Specific Directories |
|||
systemdir="${filesdir}/baseq3" |
|||
executabledir="${filesdir}" |
|||
executable="./q3ded" |
|||
servercfg="${servicename}.cfg" |
|||
servercfgdefault="server.cfg" |
|||
servercfgdir="${systemdir}" |
|||
servercfgfullpath="${servercfgdir}/${servercfg}" |
|||
|
|||
## Backup Directory |
|||
backupdir="${rootdir}/backups" |
|||
|
|||
## Logging Directories |
|||
logdir="${rootdir}/log" |
|||
gamelogdir="${systemdir}/logs" |
|||
lgsmlogdir="${logdir}/script" |
|||
consolelogdir="${logdir}/console" |
|||
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" |
@ -0,0 +1,142 @@ |
|||
#!/bin/bash |
|||
# LinuxGSM update_mumble.sh function |
|||
# Author: Daniel Gibbs |
|||
# Website: https://linuxgsm.com |
|||
# Description: Handles updating of Mumble servers. |
|||
|
|||
local commandname="UPDATE" |
|||
local commandaction="Update" |
|||
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" |
|||
|
|||
fn_update_mumble_dl(){ |
|||
fn_fetch_file "https://github.com/mvdevs/jk2mv/releases/download/${remotebuild}/jk2mv-${remotebuild}-dedicated.zip" "${tmpdir}" "jk2mv-${remotebuild}-dedicated.zip" |
|||
fn_dl_extract "${tmpdir}" "jk2mv-${remotebuild}-dedicated.zip" "${tmpdir}" |
|||
echo -e "copying to ${serverfiles}...\c" |
|||
cp -R "${tmpdir}/murmur-static_${mumblearch}-${remotebuild}/"* "${serverfiles}" |
|||
local exitcode=$? |
|||
if [ "${exitcode}" == "0" ]; then |
|||
fn_print_ok_eol_nl |
|||
fn_script_log_pass "Copying to ${serverfiles}" |
|||
fn_clear_tmp |
|||
else |
|||
fn_print_fail_eol_nl |
|||
fn_script_log_fatal "Copying to ${serverfiles}" |
|||
core_exit.sh |
|||
fi |
|||
} |
|||
|
|||
fn_update_mumble_localbuild(){ |
|||
# Gets local build info. |
|||
fn_print_dots "Checking for update: ${remotelocation}: checking local build" |
|||
# Uses executable to find local build. |
|||
cd "${executabledir}" || exit |
|||
if [ -f "${executable}" ]; then |
|||
localbuild=$(${executable} -version 2>&1 >/dev/null | awk '{print $5}') |
|||
fn_print_ok "Checking for update: ${remotelocation}: checking local build" |
|||
fn_script_log_pass "Checking local build" |
|||
else |
|||
localbuild="0" |
|||
fn_print_error "Checking for update: ${remotelocation}: checking local build" |
|||
fn_script_log_error "Checking local build" |
|||
fi |
|||
} |
|||
|
|||
fn_update_mumble_remotebuild(){ |
|||
# Gets remote build info. |
|||
remotebuild=$(${curlpath}-s "https://api.github.com/repos/mvdevs/jk2mv/releases/latest"| grep dedicated.zip | tail -1 | awk -F"/" '{ print $8 }') |
|||
if [ "${installer}" != "1" ]; then |
|||
fn_print_dots "Checking for update: ${remotelocation}: checking remote build" |
|||
# Checks if remotebuild variable has been set. |
|||
if [ -z "${remotebuild}" ]||[ "${remotebuild}" == "null" ]; then |
|||
fn_print_fail "Checking for update: ${remotelocation}: checking remote build" |
|||
fn_script_log_fatal "Checking remote build" |
|||
core_exit.sh |
|||
else |
|||
fn_print_ok "Checking for update: ${remotelocation}: checking remote build" |
|||
fn_script_log_pass "Checking remote build" |
|||
fi |
|||
else |
|||
# Checks if remotebuild variable has been set. |
|||
if [ -z "${remotebuild}" ]||[ "${remotebuild}" == "null" ]; then |
|||
fn_print_failure "Unable to get remote build" |
|||
fn_script_log_fatal "Unable to get remote build" |
|||
core_exit.sh |
|||
fi |
|||
fi |
|||
} |
|||
|
|||
fn_update_mumble_compare(){ |
|||
# Removes dots so if statement can compare version numbers. |
|||
fn_print_dots "Checking for update: ${remotelocation}" |
|||
localbuilddigit=$(echo "${localbuild}" | tr -cd '[:digit:]') |
|||
remotebuilddigit=$(echo "${remotebuild}" | tr -cd '[:digit:]') |
|||
if [ "${localbuilddigit}" -ne "${remotebuilddigit}" ]||[ "${forceupdate}" == "1" ]; then |
|||
fn_print_ok_nl "Checking for update: ${remotelocation}" |
|||
echo -en "\n" |
|||
echo -e "Update available" |
|||
echo -e "* Local build: ${red}${localbuild} ${mumblearch}${default}" |
|||
echo -e "* Remote build: ${green}${remotebuild} ${mumblearch}${default}" |
|||
fn_script_log_info "Update available" |
|||
fn_script_log_info "Local build: ${localbuild} ${mumblearch}" |
|||
fn_script_log_info "Remote build: ${remotebuild} ${mumblearch}" |
|||
fn_script_log_info "${localbuild} > ${remotebuild}" |
|||
fn_sleep_time |
|||
echo -en "\n" |
|||
echo -en "applying update.\r" |
|||
sleep 1 |
|||
echo -en "applying update..\r" |
|||
sleep 1 |
|||
echo -en "applying update...\r" |
|||
sleep 1 |
|||
echo -en "\n" |
|||
|
|||
unset updateonstart |
|||
|
|||
check_status.sh |
|||
# If server stopped. |
|||
if [ "${status}" == "0" ]; then |
|||
exitbypass=1 |
|||
fn_update_mumble_dl |
|||
exitbypass=1 |
|||
command_start.sh |
|||
exitbypass=1 |
|||
command_stop.sh |
|||
# If server started. |
|||
else |
|||
exitbypass=1 |
|||
command_stop.sh |
|||
exitbypass=1 |
|||
fn_update_mumble_dl |
|||
exitbypass=1 |
|||
command_start.sh |
|||
fi |
|||
alert="update" |
|||
alert.sh |
|||
else |
|||
fn_print_ok_nl "Checking for update: ${remotelocation}" |
|||
echo -en "\n" |
|||
echo -e "No update available" |
|||
echo -e "* Local build: ${green}${localbuild} ${mumblearch}${default}" |
|||
echo -e "* Remote build: ${green}${remotebuild} ${mumblearch}${default}" |
|||
fn_script_log_info "No update available" |
|||
fn_script_log_info "Local build: ${localbuild} ${mumblearch}" |
|||
fn_script_log_info "Remote build: ${remotebuild} ${mumblearch}" |
|||
fi |
|||
} |
|||
|
|||
# The location where the builds are checked and downloaded. |
|||
remotelocation="jk2mv.org" |
|||
|
|||
# Game server architecture. |
|||
mumblearch="x86" |
|||
|
|||
if [ "${installer}" == "1" ]; then |
|||
fn_update_mumble_remotebuild |
|||
fn_update_mumble_dl |
|||
else |
|||
fn_print_dots "Checking for update: ${remotelocation}" |
|||
fn_script_log_info "Checking for update: ${remotelocation}" |
|||
fn_update_mumble_localbuild |
|||
fn_update_mumble_remotebuild |
|||
fn_update_mumble_compare |
|||
fi |
Loading…
Reference in new issue