core_functions.sh 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458
  1. #!/bin/bash
  2. # LGSM core_functions.sh function
  3. # Author: Daniel Gibbs
  4. # Website: http://gameservermanagers.com
  5. <<<<<<< HEAD
  6. lgsm_version="190216"
  7. =======
  8. lgsm_version="270216"
  9. >>>>>>> dlmanage
  10. # Description: Defines all functions to allow download and execution of functions using fn_fetch_function.
  11. # This function is called first before any other function. Without this file other functions would not load.
  12. # Code/functions for legacy servers
  13. fn_functions(){
  14. functionfile="${FUNCNAME}"
  15. fn_fetch_function
  16. }
  17. fn_getopt(){
  18. functionfile="${FUNCNAME}"
  19. fn_fetch_function
  20. }
  21. # fn_fetch_core_dl also placed here to allow legecy servers to still download core functions
  22. if [ -z "${lgsmdir}" ]; then
  23. lgsmdir="${rootdir}/lgsm"
  24. functionsdir="${lgsmdir}/functions"
  25. fi
  26. fn_fetch_core_dl(){
  27. github_file_url_dir="functions"
  28. github_file_url_name="${functionfile}"
  29. filedir="${functionsdir}"
  30. filename="${github_file_url_name}"
  31. githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}"
  32. # If the file is missing, then download
  33. if [ ! -f "${filedir}/${filename}" ]; then
  34. if [ ! -d "${filedir}" ]; then
  35. mkdir -p "${filedir}"
  36. fi
  37. echo -e " fetching ${filename}...\c"
  38. # Check curl exists and use available path
  39. curlpaths="$(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl $(echo $PATH | sed "s/\([:]\|\$\)/\/curl /g")"
  40. for curlcmd in ${curlpaths}
  41. do
  42. if [ -x "${curlcmd}" ]; then
  43. break
  44. fi
  45. done
  46. # If curl exists download file
  47. if [ "$(basename ${curlcmd})" == "curl" ]; then
  48. curlfetch=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${githuburl}" 2>&1)
  49. if [ $? -ne 0 ]; then
  50. echo -e "\e[0;31mFAIL\e[0m\n"
  51. echo "${curlfetch}"
  52. echo -e "${githuburl}\n"
  53. exit 1
  54. else
  55. echo -e "\e[0;32mOK\e[0m"
  56. fi
  57. else
  58. echo -e "\e[0;31mFAIL\e[0m\n"
  59. echo "Curl is not installed!"
  60. echo -e ""
  61. exit 1
  62. fi
  63. chmod +x "${filedir}/${filename}"
  64. fi
  65. source "${filedir}/${filename}"
  66. }
  67. # Core
  68. core_dl.sh(){
  69. # Functions are defined in core_functions.sh.
  70. functionfile="${FUNCNAME}"
  71. fn_fetch_core_dl
  72. }
  73. core_getopt.sh(){
  74. functionfile="${FUNCNAME}"
  75. fn_fetch_core_dl
  76. }
  77. core_messages.sh(){
  78. functionfile="${FUNCNAME}"
  79. fn_fetch_core_dl
  80. }
  81. core_dl.sh(){
  82. functionfile="${FUNCNAME}"
  83. fn_fetch_core_dl
  84. }
  85. # Command
  86. command_console.sh(){
  87. functionfile="${FUNCNAME}"
  88. fn_fetch_function
  89. }
  90. command_debug.sh(){
  91. functionfile="${FUNCNAME}"
  92. fn_fetch_function
  93. }
  94. command_details.sh(){
  95. functionfile="${FUNCNAME}"
  96. fn_fetch_function
  97. }
  98. command_email_test.sh(){
  99. functionfile="${FUNCNAME}"
  100. fn_fetch_function
  101. }
  102. command_backup.sh(){
  103. functionfile="${FUNCNAME}"
  104. fn_fetch_function
  105. }
  106. command_monitor.sh(){
  107. functionfile="${FUNCNAME}"
  108. fn_fetch_function
  109. }
  110. command_start.sh(){
  111. functionfile="${FUNCNAME}"
  112. fn_fetch_function
  113. }
  114. command_stop.sh(){
  115. functionfile="${FUNCNAME}"
  116. fn_fetch_function
  117. }
  118. command_validate.sh(){
  119. functionfile="${FUNCNAME}"
  120. fn_fetch_function
  121. }
  122. command_install.sh(){
  123. functionfile="${FUNCNAME}"
  124. fn_fetch_function
  125. }
  126. command_fastdl.sh(){
  127. functionfile="${FUNCNAME}"
  128. fn_runfunction
  129. }
  130. command_ts3_server_pass.sh(){
  131. functionfile="${FUNCNAME}"
  132. fn_fetch_function
  133. }
  134. fn_restart(){
  135. local modulename="Restarting"
  136. info_config.sh
  137. if [ -d "${scriptlogdir}" ]; then
  138. fn_scriptlog "${servername}"
  139. fi
  140. command_stop.sh
  141. command_start.sh
  142. }
  143. # Checks
  144. check.sh(){
  145. functionfile="${FUNCNAME}"
  146. fn_fetch_function
  147. }
  148. check_config.sh(){
  149. functionfile="${FUNCNAME}"
  150. fn_fetch_function
  151. }
  152. check_deps.sh(){
  153. functionfile="${FUNCNAME}"
  154. fn_fetch_function
  155. }
  156. check_ip.sh(){
  157. functionfile="${FUNCNAME}"
  158. fn_fetch_function
  159. }
  160. check_logs.sh(){
  161. functionfile="${FUNCNAME}"
  162. fn_fetch_function
  163. }
  164. check_root.sh(){
  165. functionfile="${FUNCNAME}"
  166. fn_fetch_function
  167. }
  168. check_steamcmd.sh(){
  169. functionfile="${FUNCNAME}"
  170. fn_fetch_function
  171. }
  172. check_system_dir.sh(){
  173. functionfile="${FUNCNAME}"
  174. fn_fetch_function
  175. }
  176. check_tmux.sh(){
  177. functionfile="${FUNCNAME}"
  178. fn_fetch_function
  179. }
  180. # Compress
  181. compress_unreal2_maps.sh(){
  182. functionfile="${FUNCNAME}"
  183. fn_fetch_function
  184. }
  185. compress_ut99_maps.sh(){
  186. functionfile="${FUNCNAME}"
  187. fn_fetch_function
  188. }
  189. # Dev
  190. command_dev_debug.sh(){
  191. functionfile="${FUNCNAME}"
  192. fn_fetch_function
  193. }
  194. command_dev_detect_deps.sh(){
  195. functionfile="${FUNCNAME}"
  196. fn_fetch_function
  197. }
  198. # Fix
  199. fix.sh(){
  200. functionfile="${FUNCNAME}"
  201. fn_fetch_function
  202. }
  203. fix_arma3.sh(){
  204. functionfile="${FUNCNAME}"
  205. fn_fetch_function
  206. }
  207. fix_csgo.sh(){
  208. functionfile="${FUNCNAME}"
  209. fn_fetch_function
  210. }
  211. fix_dst.sh(){
  212. functionfile="${FUNCNAME}"
  213. fn_fetch_function
  214. }
  215. fix_ins.sh(){
  216. functionfile="${FUNCNAME}"
  217. fn_fetch_function
  218. }
  219. fix_steamcmd.sh(){
  220. functionfile="${FUNCNAME}"
  221. fn_fetch_function
  222. }
  223. fix_glibc.sh(){
  224. functionfile="${FUNCNAME}"
  225. fn_fetch_function
  226. }
  227. fix_ro.sh(){
  228. functionfile="${FUNCNAME}"
  229. fn_fetch_function
  230. }
  231. fix_kf.sh(){
  232. functionfile="${FUNCNAME}"
  233. fn_fetch_function
  234. }
  235. fix_ut2k4.sh(){
  236. functionfile="${FUNCNAME}"
  237. fn_fetch_function
  238. }
  239. # Info
  240. info_config.sh(){
  241. functionfile="${FUNCNAME}"
  242. fn_fetch_function
  243. }
  244. info_distro.sh(){
  245. functionfile="${FUNCNAME}"
  246. fn_fetch_function
  247. }
  248. info_glibc.sh(){
  249. functionfile="${FUNCNAME}"
  250. fn_fetch_function
  251. }
  252. info_ts3status.sh(){
  253. functionfile="${FUNCNAME}"
  254. fn_fetch_function
  255. }
  256. # Email
  257. email.sh(){
  258. functionfile="${FUNCNAME}"
  259. fn_fetch_function
  260. }
  261. # Logs
  262. logs.sh(){
  263. functionfile="${FUNCNAME}"
  264. fn_fetch_function
  265. }
  266. # Monitor
  267. monitor_gsquery.sh(){
  268. functionfile="${FUNCNAME}"
  269. fn_fetch_function
  270. }
  271. # Update
  272. update_check.sh(){
  273. functionfile="${FUNCNAME}"
  274. fn_fetch_function
  275. }
  276. command_update_functions.sh(){
  277. functionfile="${FUNCNAME}"
  278. fn_fetch_function
  279. }
  280. update_dl.sh(){
  281. functionfile="${FUNCNAME}"
  282. fn_fetch_function
  283. }
  284. fn_update_functions.sh(){
  285. functionfile="${FUNCNAME}"
  286. fn_fetch_function
  287. }
  288. #
  289. ## Installer functions
  290. #
  291. fn_autoinstall(){
  292. autoinstall=1
  293. command_install.sh
  294. }
  295. install_complete.sh(){
  296. functionfile="${FUNCNAME}"
  297. fn_fetch_function
  298. }
  299. install_config.sh(){
  300. functionfile="${FUNCNAME}"
  301. fn_fetch_function
  302. }
  303. install_gsquery.sh(){
  304. functionfile="${FUNCNAME}"
  305. fn_fetch_function
  306. }
  307. install_gslt.sh(){
  308. functionfile="${FUNCNAME}"
  309. fn_fetch_function
  310. }
  311. install_header.sh(){
  312. functionfile="${FUNCNAME}"
  313. fn_fetch_function
  314. }
  315. install_logs.sh(){
  316. functionfile="${FUNCNAME}"
  317. fn_fetch_function
  318. }
  319. install_retry.sh(){
  320. functionfile="${FUNCNAME}"
  321. fn_fetch_function
  322. }
  323. install_server_dir.sh(){
  324. functionfile="${FUNCNAME}"
  325. fn_fetch_function
  326. }
  327. install_server_files.sh(){
  328. functionfile="${FUNCNAME}"
  329. fn_fetch_function
  330. }
  331. install_steamcmd.sh(){
  332. functionfile="${FUNCNAME}"
  333. fn_fetch_function
  334. }
  335. install_ts3.sh(){
  336. functionfile="${FUNCNAME}"
  337. fn_fetch_function
  338. }
  339. install_ts3db.sh(){
  340. functionfile="${FUNCNAME}"
  341. fn_fetch_function
  342. }
  343. install_ut2k4.sh(){
  344. functionfile="${FUNCNAME}"
  345. fn_fetch_function
  346. }
  347. install_dl_ut2k4.sh(){
  348. functionfile="${FUNCNAME}"
  349. fn_fetch_function
  350. }
  351. install_ut2k4_key.sh(){
  352. functionfile="${FUNCNAME}"
  353. fn_fetch_function
  354. }
  355. fix_ut99.sh(){
  356. functionfile="${FUNCNAME}"
  357. fn_fetch_function
  358. }
  359. # Calls on-screen messages
  360. core_messages.sh
  361. #Calls file downloader
  362. core_dl.sh