jc2server 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. #!/bin/bash
  2. # Just Cause 2
  3. # Project: Game Server Managers - LinuxGSM
  4. # Author: Daniel Gibbs
  5. # License: MIT License, Copyright (c) 2016 Daniel Gibbs
  6. # Purpose: Just Cause 2 | Server Management Script
  7. # Contributors: https://github.com/GameServerManagers/LinuxGSM/graphs/contributors
  8. # Documentation: https://github.com/GameServerManagers/LinuxGSM/wiki
  9. # Website: https://gameservermanagers.com
  10. # Debugging
  11. if [ -f ".dev-debug" ]; then
  12. exec 5>dev-debug.log
  13. BASH_XTRACEFD="5"
  14. set -x
  15. fi
  16. version="161113"
  17. ##########################
  18. ######## Settings ########
  19. ##########################
  20. #### Server Settings ####
  21. # No settings available for Just Cause 2
  22. ## Server Start Command | https://github.com/GameServerManagers/LinuxGSM/wiki/Start-Parameters#additional-parameters
  23. # Edit with care
  24. fn_parms(){
  25. parms=""
  26. }
  27. #### LinuxGSM Settings ####
  28. ## Notification Alerts
  29. # (on|off)
  30. # Email Alerts | https://github.com/GameServerManagers/LinuxGSM/wiki/Email
  31. emailalert="off"
  32. email="email@example.com"
  33. emailfrom=""
  34. # Pushbullet Alerts | https://github.com/GameServerManagers/LinuxGSM/wiki/Pushbullet
  35. pushbulletalert="off"
  36. pushbullettoken="accesstoken"
  37. channeltag=""
  38. ## Updating | https://github.com/GameServerManagers/LinuxGSM/wiki/Update
  39. updateonstart="off"
  40. ## Backup | https://github.com/GameServerManagers/LinuxGSM/wiki/Backup
  41. maxbackups="4"
  42. maxbackupdays="30"
  43. stoponbackup="on"
  44. ## Logging | https://github.com/GameServerManagers/LinuxGSM/wiki/Logging
  45. consolelogging="on"
  46. logdays="7"
  47. #### LinuxGSM Advanced Settings ####
  48. ## SteamCMD Settings
  49. # Server appid
  50. appid="261140"
  51. # Steam App Branch Select
  52. # Allows to opt into the various Steam app branches. Default branch is "".
  53. # Example: "-beta latest_experimental"
  54. branch=""
  55. ## Github Branch Select
  56. # Allows for the use of different function files
  57. # from a different repo and/or branch.
  58. githubuser="GameServerManagers"
  59. githubrepo="LinuxGSM"
  60. githubbranch="master"
  61. ## LinuxGSM Server Details
  62. # Do not edit
  63. gamename="Just Cause 2"
  64. engine="avalanche"
  65. ## Service Name | https://github.com/GameServerManagers/LinuxGSM/wiki/Multiple-Servers
  66. servicename="jc2-server"
  67. #### Directories ####
  68. # Edit with care
  69. ## Work Directories
  70. rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))"
  71. selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
  72. lockselfname=".${servicename}.lock"
  73. lgsmdir="${rootdir}/lgsm"
  74. functionsdir="${lgsmdir}/functions"
  75. libdir="${lgsmdir}/lib"
  76. tmpdir="${lgsmdir}/tmp"
  77. filesdir="${rootdir}/serverfiles"
  78. ## Server Specific Directories
  79. systemdir="${filesdir}"
  80. executabledir="${filesdir}"
  81. executable="./Jcmp-Server"
  82. servercfg="config.lua"
  83. servercfgdefault="config.lua"
  84. servercfgdir="${filesdir}"
  85. servercfgfullpath="${servercfgdir}/${servercfg}"
  86. ## Backup Directory
  87. backupdir="${rootdir}/backups"
  88. ## Logging Directories
  89. #gamelogdir="" # No server logs available
  90. scriptlogdir="${rootdir}/log/script"
  91. consolelogdir="${rootdir}/log/console"
  92. scriptlog="${scriptlogdir}/${servicename}-script.log"
  93. consolelog="${consolelogdir}/${servicename}-console.log"
  94. emaillog="${scriptlogdir}/${servicename}-email.log"
  95. ## Logs Naming
  96. scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%Y-%m-%d-%H:%M:%S').log"
  97. consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%Y-%m-%d-%H:%M:%S').log"
  98. ########################
  99. ######## Script ########
  100. ###### Do not edit #####
  101. ########################
  102. # Fetches core_dl for file downloads
  103. fn_fetch_core_dl(){
  104. github_file_url_dir="lgsm/functions"
  105. github_file_url_name="${functionfile}"
  106. filedir="${functionsdir}"
  107. filename="${github_file_url_name}"
  108. githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}"
  109. # If the file is missing, then download
  110. if [ ! -f "${filedir}/${filename}" ]; then
  111. if [ ! -d "${filedir}" ]; then
  112. mkdir -p "${filedir}"
  113. fi
  114. echo -e " fetching ${filename}...\c"
  115. # Check curl exists and use available path
  116. curlpaths="$(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl)"
  117. for curlcmd in ${curlpaths}
  118. do
  119. if [ -x "${curlcmd}" ]; then
  120. break
  121. fi
  122. done
  123. # If curl exists download file
  124. if [ "$(basename ${curlcmd})" == "curl" ]; then
  125. curlfetch=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${githuburl}" 2>&1)
  126. if [ $? -ne 0 ]; then
  127. echo -e "\e[0;31mFAIL\e[0m\n"
  128. echo "${curlfetch}"
  129. echo -e "${githuburl}\n"
  130. exit 1
  131. else
  132. echo -e "\e[0;32mOK\e[0m"
  133. fi
  134. else
  135. echo -e "\e[0;31mFAIL\e[0m\n"
  136. echo "Curl is not installed!"
  137. echo -e ""
  138. exit 1
  139. fi
  140. chmod +x "${filedir}/${filename}"
  141. fi
  142. source "${filedir}/${filename}"
  143. }
  144. core_dl.sh(){
  145. # Functions are defined in core_functions.sh.
  146. functionfile="${FUNCNAME}"
  147. fn_fetch_core_dl
  148. }
  149. core_functions.sh(){
  150. # Functions are defined in core_functions.sh.
  151. functionfile="${FUNCNAME}"
  152. fn_fetch_core_dl
  153. }
  154. # Prevent from running this script as root.
  155. if [ "$(whoami)" = "root" ]; then
  156. if [ ! -f "${functionsdir}/core_functions.sh" ]||[ ! -f "${functionsdir}/check_root.sh" ]||[ ! -f "${functionsdir}/core_messages.sh" ]||[ ! -f "${functionsdir}/core_exit.sh" ]; then
  157. echo "[ FAIL ] Do NOT run this script as root!"
  158. exit 1
  159. else
  160. core_functions.sh
  161. check_root.sh
  162. fi
  163. fi
  164. core_dl.sh
  165. core_functions.sh
  166. getopt=$1
  167. core_getopt.sh