jc2server 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. #!/bin/bash
  2. # Just Cause 2
  3. # Server Management Script
  4. # Author: Daniel Gibbs
  5. # Website: http://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="271215"
  12. #### Variables ####
  13. # Notification Email
  14. # (on|off)
  15. emailnotification="off"
  16. email="email@example.com"
  17. # Steam login
  18. steamuser="anonymous"
  19. steampass=""
  20. # Start Variables
  21. updateonstart="off"
  22. fn_parms(){
  23. parms=""
  24. }
  25. #### Advanced Variables ####
  26. # Github Branch Select
  27. # Allows for the use of different function files
  28. # from a different repo and/or branch.
  29. githubuser="dgibbs64"
  30. githubrepo="linuxgsm"
  31. githubbranch="master"
  32. # Steam
  33. appid="261140"
  34. # Server Details
  35. servicename="jc2-server"
  36. gamename="Just Cause 2"
  37. engine="avalanche"
  38. # Directories
  39. rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))"
  40. selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
  41. lockselfname=".${servicename}.lock"
  42. filesdir="${rootdir}/serverfiles"
  43. systemdir="${filesdir}"
  44. executabledir="${filesdir}"
  45. executable="./Jcmp-Server"
  46. servercfg="config.lua"
  47. servercfgdir="${filesdir}"
  48. servercfgfullpath="${servercfgdir}/${servercfg}"
  49. servercfgdefault="${servercfgdir}/default_config.lua"
  50. backupdir="${rootdir}/backups"
  51. # Logging
  52. logdays="7"
  53. #gamelogdir="" # No server logs available
  54. scriptlogdir="${rootdir}/log/script"
  55. consolelogdir="${rootdir}/log/console"
  56. scriptlog="${scriptlogdir}/${servicename}-script.log"
  57. consolelog="${consolelogdir}/${servicename}-console.log"
  58. emaillog="${scriptlogdir}/${servicename}-email.log"
  59. scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log"
  60. consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%d-%m-%Y-%H-%M-%S').log"
  61. ##### Script #####
  62. # Do not edit
  63. fn_getgithubfile(){
  64. filename=$1
  65. exec=$2
  66. fileurl=${3:-$filename}
  67. filepath="${rootdir}/${filename}"
  68. filedir=$(dirname "${filepath}")
  69. # If the function file is missing, then download
  70. if [ ! -f "${filepath}" ]; then
  71. if [ ! -d "${filedir}" ]; then
  72. mkdir "${filedir}"
  73. fi
  74. githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${fileurl}"
  75. echo -e " fetching ${filename}...\c"
  76. if [ "$(command -v curl)" ]||[ "$(which curl >/dev/null 2>&1)" ]||[ -f "/usr/bin/curl" ]||[ -f "/bin/curl" ]; then
  77. :
  78. else
  79. echo -e "\e[0;31mFAIL\e[0m\n"
  80. echo "Curl is not installed!"
  81. echo -e ""
  82. exit
  83. fi
  84. curl=$(curl --fail -o "${filepath}" "${githuburl}" 2>&1)
  85. if [ $? -ne 0 ]; then
  86. echo -e "\e[0;31mFAIL\e[0m\n"
  87. echo "${curl}"
  88. echo -e "${githuburl}\n"
  89. exit
  90. else
  91. echo -e "\e[0;32mOK\e[0m"
  92. fi
  93. if [ "${exec}" ]; then
  94. chmod +x "${filepath}"
  95. fi
  96. fi
  97. if [ "${exec}" ]; then
  98. source "${filepath}"
  99. fi
  100. }
  101. fn_runfunction(){
  102. fn_getgithubfile "functions/${functionfile}" 1
  103. }
  104. core_functions.sh(){
  105. # Functions are defined in core_functions.sh.
  106. functionfile="${FUNCNAME}"
  107. fn_runfunction
  108. }
  109. core_functions.sh
  110. getopt=$1
  111. core_getopt.sh