core_functions.sh 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  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. if [ -d "${scriptlogdir}" ]; then
  130. fn_scriptlog "${servername}"
  131. fi
  132. command_stop.sh
  133. command_start.sh
  134. }
  135. # Checks
  136. check.sh(){
  137. functionfile="${FUNCNAME}"
  138. fn_fetch_function
  139. }
  140. check_config.sh(){
  141. functionfile="${FUNCNAME}"
  142. fn_fetch_function
  143. }
  144. check_deps.sh(){
  145. functionfile="${FUNCNAME}"
  146. fn_fetch_function
  147. }
  148. check_ip.sh(){
  149. functionfile="${FUNCNAME}"
  150. fn_fetch_function
  151. }
  152. check_logs.sh(){
  153. functionfile="${FUNCNAME}"
  154. fn_fetch_function
  155. }
  156. check_root.sh(){
  157. functionfile="${FUNCNAME}"
  158. fn_fetch_function
  159. }
  160. check_steamcmd.sh(){
  161. functionfile="${FUNCNAME}"
  162. fn_fetch_function
  163. }
  164. check_system_dir.sh(){
  165. functionfile="${FUNCNAME}"
  166. fn_fetch_function
  167. }
  168. check_tmux.sh(){
  169. functionfile="${FUNCNAME}"
  170. fn_fetch_function
  171. }
  172. # Compress
  173. compress_unreal2_maps.sh(){
  174. functionfile="${FUNCNAME}"
  175. fn_fetch_function
  176. }
  177. compress_ut99_maps.sh(){
  178. functionfile="${FUNCNAME}"
  179. fn_fetch_function
  180. }
  181. # Dev
  182. command_dev_debug.sh(){
  183. functionfile="${FUNCNAME}"
  184. fn_fetch_function
  185. }
  186. command_dev_detect_deps.sh(){
  187. functionfile="${FUNCNAME}"
  188. fn_fetch_function
  189. }
  190. # Fix
  191. fix.sh(){
  192. functionfile="${FUNCNAME}"
  193. fn_fetch_function
  194. }
  195. fix_arma3.sh(){
  196. functionfile="${FUNCNAME}"
  197. fn_fetch_function
  198. }
  199. fix_csgo.sh(){
  200. functionfile="${FUNCNAME}"
  201. fn_fetch_function
  202. }
  203. fix_dst.sh(){
  204. functionfile="${FUNCNAME}"
  205. fn_fetch_function
  206. }
  207. fix_ins.sh(){
  208. functionfile="${FUNCNAME}"
  209. fn_fetch_function
  210. }
  211. fix_steamcmd.sh(){
  212. functionfile="${FUNCNAME}"
  213. fn_fetch_function
  214. }
  215. fix_glibc.sh(){
  216. functionfile="${FUNCNAME}"
  217. fn_fetch_function
  218. }
  219. fix_ro.sh(){
  220. functionfile="${FUNCNAME}"
  221. fn_fetch_function
  222. }
  223. fix_kf.sh(){
  224. functionfile="${FUNCNAME}"
  225. fn_fetch_function
  226. }
  227. fix_ut2k4.sh(){
  228. functionfile="${FUNCNAME}"
  229. fn_fetch_function
  230. }
  231. # Info
  232. info_config.sh(){
  233. functionfile="${FUNCNAME}"
  234. fn_fetch_function
  235. }
  236. info_distro.sh(){
  237. functionfile="${FUNCNAME}"
  238. fn_fetch_function
  239. }
  240. info_glibc.sh(){
  241. functionfile="${FUNCNAME}"
  242. fn_fetch_function
  243. }
  244. info_ts3status.sh(){
  245. functionfile="${FUNCNAME}"
  246. fn_fetch_function
  247. }
  248. # Email
  249. email.sh(){
  250. functionfile="${FUNCNAME}"
  251. fn_fetch_function
  252. }
  253. # Logs
  254. logs.sh(){
  255. functionfile="${FUNCNAME}"
  256. fn_fetch_function
  257. }
  258. # Monitor
  259. monitor_gsquery.sh(){
  260. functionfile="${FUNCNAME}"
  261. fn_fetch_function
  262. }
  263. # Update
  264. update_check.sh(){
  265. functionfile="${FUNCNAME}"
  266. fn_fetch_function
  267. }
  268. command_update_functions.sh(){
  269. functionfile="${FUNCNAME}"
  270. fn_fetch_function
  271. }
  272. update_dl.sh(){
  273. functionfile="${FUNCNAME}"
  274. fn_fetch_function
  275. }
  276. fn_update_functions.sh(){
  277. functionfile="${FUNCNAME}"
  278. fn_fetch_function
  279. }
  280. #
  281. ## Installer functions
  282. #
  283. fn_autoinstall(){
  284. autoinstall=1
  285. command_install.sh
  286. }
  287. install_complete.sh(){
  288. functionfile="${FUNCNAME}"
  289. fn_fetch_function
  290. }
  291. install_config.sh(){
  292. functionfile="${FUNCNAME}"
  293. fn_fetch_function
  294. }
  295. install_gsquery.sh(){
  296. functionfile="${FUNCNAME}"
  297. fn_fetch_function
  298. }
  299. install_gslt.sh(){
  300. functionfile="${FUNCNAME}"
  301. fn_fetch_function
  302. }
  303. install_header.sh(){
  304. functionfile="${FUNCNAME}"
  305. fn_fetch_function
  306. }
  307. install_logs.sh(){
  308. functionfile="${FUNCNAME}"
  309. fn_fetch_function
  310. }
  311. install_retry.sh(){
  312. functionfile="${FUNCNAME}"
  313. fn_fetch_function
  314. }
  315. install_server_dir.sh(){
  316. functionfile="${FUNCNAME}"
  317. fn_fetch_function
  318. }
  319. install_server_files.sh(){
  320. functionfile="${FUNCNAME}"
  321. fn_fetch_function
  322. }
  323. install_steamcmd.sh(){
  324. functionfile="${FUNCNAME}"
  325. fn_fetch_function
  326. }
  327. install_ts3.sh(){
  328. functionfile="${FUNCNAME}"
  329. fn_fetch_function
  330. }
  331. install_ts3db.sh(){
  332. functionfile="${FUNCNAME}"
  333. fn_fetch_function
  334. }
  335. install_ut2k4.sh(){
  336. functionfile="${FUNCNAME}"
  337. fn_fetch_function
  338. }
  339. install_dl_ut2k4.sh(){
  340. functionfile="${FUNCNAME}"
  341. fn_fetch_function
  342. }
  343. install_ut2k4_key.sh(){
  344. functionfile="${FUNCNAME}"
  345. fn_fetch_function
  346. }
  347. fix_ut99.sh(){
  348. functionfile="${FUNCNAME}"
  349. fn_fetch_function
  350. }
  351. # Calls on-screen messages
  352. core_messages.sh
  353. #Calls file downloader
  354. core_dl.sh