ns2server 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #!/bin/bash
  2. # Natural Selection 2
  3. # Server Management Script
  4. # Author: Daniel Gibbs
  5. # Website: http://danielgibbs.co.uk
  6. # Version: 210115
  7. #### Variables ####
  8. # Notification Email
  9. # (on|off)
  10. emailnotification="off"
  11. email="email@example.com"
  12. # Steam login
  13. steamuser="username"
  14. steampass="password"
  15. # Start Variables
  16. defaultmap="ns2_summit"
  17. port="27015"
  18. maxplayers="24"
  19. ip="0.0.0.0"
  20. servername="NS2 Server"
  21. webadminuser="admin"
  22. webadminpass="admin"
  23. webadminport="8080"
  24. configpath="server1"
  25. modstorage="server1/Workshop"
  26. mods=""
  27. password=""
  28. # Add the following line to the parms if you want a private server. Ensuring
  29. # that the password variable above is not left empty.
  30. # -password \"${password}\"
  31. # http://wiki.unknownworlds.com/ns2/Dedicated_Server
  32. fn_parms(){
  33. parms="-name \"${servername}\" -port ${port} -webadmin -webdomain ${ip} -webuser ${webadminuser} -webpassword \"${webadminpass}\" -webport ${webadminport} -map ${defaultmap} -limit ${maxplayers} -config_path \"${rootdir}/${configpath}\" -modstorage \"${rootdir}/${modstorage}\" -mods \"${mods}\""
  34. }
  35. #### Advanced Variables ####
  36. # Steam
  37. appid="4940"
  38. # Server Details
  39. servicename="ns2-server"
  40. gamename="Natural Selection 2"
  41. engine="spark"
  42. # Directories
  43. rootdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
  44. selfname="$(basename $0)"
  45. lockselfname=".${servicename}.lock"
  46. filesdir="${rootdir}/serverfiles"
  47. systemdir="${filesdir}"
  48. executabledir="${filesdir}"
  49. executable="./server_linux32"
  50. backupdir="${rootdir}/backups"
  51. # Logging
  52. logdays="7"
  53. gamelogdir="${systemdir}/logs"
  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_runfunction(){
  64. # Functions are downloaded and run with this function
  65. if [ ! -f "${rootdir}/functions/${functionfile}" ]; then
  66. cd "${rootdir}"
  67. if [ ! -d "functions" ]; then
  68. mkdir functions
  69. fi
  70. cd functions
  71. echo -e "loading ${functionfile}...\c"
  72. wget -N --no-check-certificate /dev/null https://raw.githubusercontent.com/dgibbs64/linuxgameservers/master/functions/${functionfile} 2>&1 | grep -F HTTP | cut -c45-
  73. chmod +x "${functionfile}"
  74. cd "${rootdir}"
  75. sleep 1
  76. fi
  77. source "${rootdir}/functions/${functionfile}"
  78. }
  79. fn_functions(){
  80. # Functions are defined in fn_functions.
  81. functionfile="${FUNCNAME}"
  82. fn_runfunction
  83. }
  84. fn_functions
  85. getopt=$1
  86. fn_getopt