command_update_functions.sh 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/bin/bash
  2. # LGSM command_update_functions.sh function
  3. # Author: Daniel Gibbs
  4. # Website: https://gameservermanagers.com
  5. lgsm_version="210516"
  6. # Description: Deletes the functions dir to allow re-downloading of functions from GitHub.
  7. function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
  8. check.sh
  9. fn_print_dots "Updating functions"
  10. fn_script_log_info "Updating functions"
  11. sleep 1
  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. #functionfile=core_exit.sh
  26. echo "FUNCTIONFILE: ${functionfile}"
  27. function_file_diff=$(diff "${functionsdir}/${functionfile}" <(curl -s https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}))
  28. if [ "${function_file_diff}" != "" ]; then
  29. echo "rm -rfv ${functionsdir}/${functionfile}"
  30. rm -rfv "${functionsdir}/${functionfile}"
  31. fn_update_function
  32. core_exit.sh
  33. fi
  34. done
  35. fi
  36. fi
  37. if [ "${exitcode}" == "0" ]; then
  38. fn_print_ok "Updating functions"
  39. fn_script_log_pass "Success! Updating functions"
  40. exitcode=0
  41. else
  42. fn_print_fail "Updating functions"
  43. fn_script_log_fatal "Failure! Updating functions"
  44. exitcode=1
  45. fi
  46. echo -ne "\n"
  47. core_exit.sh