mumbleserver 3.4 KB

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