bf1942server 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. #!/bin/bash
  2. # Battlefield: 1942
  3. # Server Management Script
  4. # Author: Daniel Gibbs
  5. # Website: https://gameservermanagers.com
  6. if [ -f ".dev-debug" ]; then
  7. exec 5>dev-debug.log
  8. BASH_XTRACEFD="5"
  9. set -x
  10. fi
  11. version="210516"
  12. #### Variables ####
  13. # Notification Alerts
  14. # (on|off)
  15. # Email
  16. emailalert="off"
  17. email="email@example.com"
  18. #emailfrom="email@example.com"
  19. # Pushbullet
  20. # https://www.pushbullet.com/#settings
  21. pushbulletalert="off"
  22. pushbullettoken="accesstoken"
  23. # Start Variables
  24. fn_parms(){
  25. parms="+hostServer 1 +dedicated 1"
  26. }
  27. #### Advanced Variables ####
  28. # Github Branch Select
  29. # Allows for the use of different function files
  30. # from a different repo and/or branch.
  31. githubuser="GameServerManagers"
  32. githubrepo="LinuxGSM"
  33. githubbranch="master"
  34. # Server Details
  35. servicename="bf1942-server"
  36. gamename="Battlefield: 1942"
  37. engine="refractor"
  38. # Directories
  39. rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))"
  40. selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
  41. lockselfname=".${servicename}.lock"
  42. lgsmdir="${rootdir}/lgsm"
  43. functionsdir="${lgsmdir}/functions"
  44. libdir="${lgsmdir}/lib"
  45. tmpdir="${lgsmdir}/tmp"
  46. filesdir="${rootdir}/serverfiles"
  47. systemdir="${filesdir}"
  48. executabledir="${systemdir}"
  49. executable="./start.sh"
  50. servercfg="serversettings.con"
  51. servercfgdefault="serversettings.con"
  52. servercfgdir="${systemdir}/mods/bf1942/settings"
  53. servercfgfullpath="${servercfgdir}/${servercfg}"
  54. backupdir="${rootdir}/backups"
  55. # Logging
  56. logdays="7"
  57. gamelogdir="${filesdir}/Logs"
  58. scriptlogdir="${rootdir}/log/script"
  59. consolelogdir="${rootdir}/log/console"
  60. consolelogging="on"
  61. scriptlog="${scriptlogdir}/${servicename}-script.log"
  62. consolelog="${consolelogdir}/${servicename}-console.log"
  63. emaillog="${scriptlogdir}/${servicename}-email.log"
  64. scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log"
  65. consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%d-%m-%Y-%H-%M-%S').log"
  66. ##### Script #####
  67. # Do not edit
  68. # Fetches core_dl for file downloads
  69. fn_fetch_core_dl(){
  70. github_file_url_dir="lgsm/functions"
  71. github_file_url_name="${functionfile}"
  72. filedir="${functionsdir}"
  73. filename="${github_file_url_name}"
  74. githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}"
  75. # If the file is missing, then download
  76. if [ ! -f "${filedir}/${filename}" ]; then
  77. if [ ! -d "${filedir}" ]; then
  78. mkdir -p "${filedir}"
  79. fi
  80. echo -e " fetching ${filename}...\c"
  81. # Check curl exists and use available path
  82. curlpaths="$(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl)"
  83. for curlcmd in ${curlpaths}
  84. do
  85. if [ -x "${curlcmd}" ]; then
  86. break
  87. fi
  88. done
  89. # If curl exists download file
  90. if [ "$(basename ${curlcmd})" == "curl" ]; then
  91. curlfetch=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${githuburl}" 2>&1)
  92. if [ $? -ne 0 ]; then
  93. echo -e "\e[0;31mFAIL\e[0m\n"
  94. echo "${curlfetch}"
  95. echo -e "${githuburl}\n"
  96. exit 1
  97. else
  98. echo -e "\e[0;32mOK\e[0m"
  99. fi
  100. else
  101. echo -e "\e[0;31mFAIL\e[0m\n"
  102. echo "Curl is not installed!"
  103. echo -e ""
  104. exit 1
  105. fi
  106. chmod +x "${filedir}/${filename}"
  107. fi
  108. source "${filedir}/${filename}"
  109. }
  110. core_dl.sh(){
  111. # Functions are defined in core_functions.sh.
  112. functionfile="${FUNCNAME}"
  113. fn_fetch_core_dl
  114. }
  115. core_functions.sh(){
  116. # Functions are defined in core_functions.sh.
  117. functionfile="${FUNCNAME}"
  118. fn_fetch_core_dl
  119. }
  120. core_dl.sh
  121. core_functions.sh
  122. getopt=$1
  123. core_getopt.sh