command_update_functions.sh 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #!/bin/bash
  2. # LinuxGSM command_update_functions.sh function
  3. # Author: Daniel Gibbs
  4. # Website: https://gameservermanagers.com
  5. # Description: Deletes the functions dir to allow re-downloading of functions from GitHub.
  6. local commandname="UPDATE LinuxGSM"
  7. local commandaction="Update LinuxGSM"
  8. local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
  9. fn_print_dots "Updating LinuxGSM"
  10. sleep 1
  11. check.sh
  12. fn_script_log_info "Updating LinuxGSM"
  13. echo -ne "\n"
  14. # Check and update _default.cfg
  15. echo -ne " checking config _default.cfg...\c"
  16. config_file_diff=$(diff "${configdirdefault}/config-lgsm/${servername}/_default.cfg" <(${curlpath} -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/config-default/config-lgsm/${servername}/_default.cfg"))
  17. if [ "${config_file_diff}" != "" ]; then
  18. fn_print_update_eol_nl
  19. fn_script_log_info "checking config _default.cfg: UPDATE"
  20. rm -f "${configdirdefault}/config-lgsm/${servername}/_default.cfg"
  21. fn_fetch_config "lgsm/config-default/config-lgsm/${servername}" "_default.cfg" "${configdirdefault}/config-lgsm/${servername}" "_default.cfg" "noexecutecmd" "norun" "noforce" "nomd5"
  22. else
  23. fn_print_ok_eol_nl
  24. fi
  25. echo -ne " checking ${selfname}...\c"
  26. config_script_diff=$(diff "${tmpdir}/linuxgsm.sh" <(${curlpath} -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/linuxgsm.sh"))
  27. if [ "${config_file_diff}" != "" ]; then
  28. fn_print_update_eol_nl
  29. fn_script_log_info "checking ${selfname}: UPDATE"
  30. rm -f "${tmpdir}/linuxgsm.sh"
  31. fn_fetch_file_github "" "linuxgsm.sh" "${tmpdir}" "linuxgsm.sh" "noexecutecmd" "norun" "noforce" "nomd5"
  32. else
  33. fn_print_ok_eol_nl
  34. fi
  35. # Check and update functions
  36. if [ -n "${functionsdir}" ]; then
  37. if [ -d "${functionsdir}" ]; then
  38. cd "${functionsdir}"
  39. for functionfile in *
  40. do
  41. echo -ne " checking function ${functionfile}...\c"
  42. function_file_diff=$(diff "${functionsdir}/${functionfile}" <(${curlpath} -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}"))
  43. if [ "${function_file_diff}" != "" ]; then
  44. fn_print_update_eol_nl
  45. fn_script_log_info "checking function ${functionfile}: UPDATE"
  46. rm -rf "${functionsdir}/${functionfile}"
  47. fn_update_function
  48. else
  49. fn_print_ok_eol_nl
  50. fi
  51. done
  52. fi
  53. fi
  54. if [ "${exitcode}" != "0" ]&&[ -n "${exitcode}" ]; then
  55. fn_print_fail "Updating functions"
  56. fn_script_log_fatal "Updating functions"
  57. else
  58. fn_print_ok "Updating functions"
  59. fn_script_log_pass "Updating functions"
  60. fi
  61. echo -ne "\n"
  62. core_exit.sh