core_functions.sh 6.7 KB

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