command_update_functions.sh 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. # Check and update functions
  26. if [ -n "${functionsdir}" ]; then
  27. if [ -d "${functionsdir}" ]; then
  28. cd "${functionsdir}"
  29. for functionfile in *
  30. do
  31. echo -ne " checking function ${functionfile}...\c"
  32. function_file_diff=$(diff "${functionsdir}/${functionfile}" <(${curlpath} -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}"))
  33. if [ "${function_file_diff}" != "" ]; then
  34. fn_print_update_eol_nl
  35. fn_script_log_info "checking function ${functionfile}: UPDATE"
  36. rm -rf "${functionsdir}/${functionfile}"
  37. fn_update_function
  38. else
  39. fn_print_ok_eol_nl
  40. fi
  41. done
  42. fi
  43. fi
  44. if [ "${exitcode}" != "0" ]&&[ -n "${exitcode}" ]; then
  45. fn_print_fail "Updating functions"
  46. fn_script_log_fatal "Updating functions"
  47. else
  48. fn_print_ok "Updating functions"
  49. fn_script_log_pass "Updating functions"
  50. fi
  51. echo -ne "\n"
  52. core_exit.sh