core_functions.sh 6.6 KB

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