jc2server 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. #!/bin/bash
  2. # Just Cause 2
  3. # Server Management Script
  4. # Author: Daniel Gibbs
  5. # Website: http://danielgibbs.co.uk
  6. # Version: 010115
  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. maxplayers="10"
  17. port="7777"
  18. ip="0.0.0.0"
  19. fn_parms(){
  20. parms="--maxplayers ${maxplayers} --bindip ${ip} --bindport ${port}"
  21. }
  22. #### Advanced Variables ####
  23. # Steam
  24. appid="261140"
  25. # Server Details
  26. servicename="jc2-server"
  27. gamename="Just Cause 2"
  28. engine="avalanche"
  29. # Directories
  30. rootdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
  31. selfname="$0"
  32. lockselfname=$(echo ".${servicename}.lock")
  33. filesdir="${rootdir}/serverfiles"
  34. systemdir="${filesdir}"
  35. executabledir="${filesdir}"
  36. executable="./Jcmp-Server"
  37. servercfgdir="${filesdir}"
  38. servercfg="config.lua"
  39. servercfgfullpath="${servercfgdir}/${servercfg}"
  40. backupdir="backups"
  41. # Server Details
  42. servername=$(grep -s hostname "${servercfgfullpath}"|sed 's/hostname //g'|sed 's/"//g')
  43. # Logging
  44. logdays="7"
  45. #gamelogdir="" # No server logs available
  46. scriptlogdir="${rootdir}/log/script"
  47. consolelogdir="${rootdir}/log/console"
  48. scriptlog="${scriptlogdir}/${servicename}-script.log"
  49. consolelog="${consolelogdir}/${servicename}-console.log"
  50. emaillog="${scriptlogdir}/${servicename}-email.log"
  51. scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log"
  52. consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%d-%m-%Y-%H-%M-%S').log"
  53. ##### Script #####
  54. # Do not edit
  55. fn_install(){
  56. fn_rootcheck
  57. fn_header
  58. if [ -z "${autoinstall}" ]; then
  59. fn_serverdirectory
  60. fn_header
  61. fi
  62. fn_steamdl
  63. fn_steaminstall
  64. fn_glibcfix
  65. fn_loginstall
  66. fn_getquery
  67. fn_serverconfig
  68. fn_header
  69. fn_details
  70. fn_installcomplete
  71. }
  72. fn_functions(){
  73. # Functions are defines in fn_functions.
  74. functionfile="${FUNCNAME}"
  75. fn_runfunction
  76. }
  77. fn_runfunction(){
  78. # Functions are downloaded and run with this function
  79. if [ ! -f "${rootdir}/functions/${functionfile}" ]; then
  80. cd "${rootdir}"
  81. if [ ! -d "functions" ]; then
  82. mkdir functions
  83. fi
  84. cd functions
  85. echo -e "loading ${functionfile}...\c"
  86. wget -N --no-check-certificate /dev/null https://raw.githubusercontent.com/dgibbs64/linuxgameservers/master/functions/${functionfile} 2>&1 | grep -F HTTP | cut -c45-
  87. chmod +x "${functionfile}"
  88. cd "${rootdir}"
  89. sleep 1
  90. fi
  91. source "${rootdir}/functions/${functionfile}"
  92. }
  93. fn_functions
  94. case "$1" in
  95. start)
  96. fn_startserver;;
  97. stop)
  98. fn_stopserver;;
  99. restart)
  100. fn_restartserver;;
  101. update)
  102. norestart=1;
  103. fn_versioncheck;;
  104. update-restart)
  105. fn_versioncheck;;
  106. validate)
  107. fn_validateserver;;
  108. validate-restart)
  109. fn_stopserver
  110. fn_validateserver
  111. fn_startserver;;
  112. monitor)
  113. fn_monitorserver;;
  114. email-test)
  115. fn_emailtest;;
  116. details)
  117. fn_details;;
  118. backup)
  119. fn_backupserver;;
  120. console)
  121. fn_console;;
  122. debug)
  123. fn_debugserver;;
  124. install)
  125. fn_install;;
  126. auto-install)
  127. fn_autoinstall;;
  128. *)
  129. echo "Usage: $0 {start|stop|restart|update|update-restart|validate|validate-restart|monitor|email-test|details|backup|console|debug|install|auto-install}"
  130. exit 1;;
  131. esac
  132. exit