4
0

jc2server 2.7 KB

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