command_update_functions.sh 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/bin/bash
  2. # LGSM 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 commandaction="Update LGSM"
  7. local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
  8. fn_print_dots "Updating functions"
  9. sleep 1
  10. check.sh
  11. fn_script_log_info "Updating functions"
  12. echo -ne "\n"
  13. # Removed legecy functions dir
  14. if [ -n "${rootdir}" ]; then
  15. if [ -d "${rootdir}/functions/" ]; then
  16. rm -rfv "${rootdir}/functions/"
  17. exitcode=$?
  18. fi
  19. fi
  20. if [ -n "${functionsdir}" ]; then
  21. if [ -d "${functionsdir}" ]; then
  22. cd "${functionsdir}"
  23. for functionfile in *
  24. do
  25. # Check curl exists and use available path
  26. curlpaths="$(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl)"
  27. for curlcmd in ${curlpaths}
  28. do
  29. if [ -x "${curlcmd}" ]; then
  30. curlcmd=${curlcmd}
  31. break
  32. fi
  33. done
  34. echo -ne " checking ${functionfile}...\c"
  35. function_file_diff=$(diff "${functionsdir}/${functionfile}" <(${curlcmd} -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}"))
  36. if [ "${function_file_diff}" != "" ]; then
  37. fn_print_update_eol_nl
  38. fn_script_log_info "checking ${functionfile}: UPDATE"
  39. rm -rf "${functionsdir}/${functionfile}"
  40. fn_update_function
  41. else
  42. fn_print_ok_eol_nl
  43. fi
  44. done
  45. fi
  46. fi
  47. if [ "${exitcode}" != "0" ]&&[ -n "${exitcode}" ]; then
  48. fn_print_fail "Updating functions"
  49. fn_script_log_fatal "Updating functions"
  50. else
  51. fn_print_ok "Updating functions"
  52. fn_script_log_pass "Updating functions"
  53. fi
  54. echo -ne "\n"
  55. core_exit.sh