4
0

core_functions.sh 6.7 KB

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