| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- #!/bin/bash
- # LGSM command_update_functions.sh function
- # Author: Daniel Gibbs
- # Website: https://gameservermanagers.com
- lgsm_version="210516"
- # Description: Deletes the functions dir to allow re-downloading of functions from GitHub.
- function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
- check.sh
- fn_print_dots "Updating functions"
- fn_script_log_info "Updating functions"
- sleep 1
- echo -ne "\n"
- # Removed legecy functions dir
- if [ -n "${rootdir}" ]; then
- if [ -d "${rootdir}/functions/" ]; then
- rm -rfv "${rootdir}/functions/"
- exitcode=$?
- fi
- fi
- if [ -n "${functionsdir}" ]; then
- if [ -d "${functionsdir}" ]; then
- cd "${functionsdir}"
- for functionfile in *
- do
- # Check curl exists and use available path
- curlpaths="$(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl)"
- for curlcmd in ${curlpaths}
- do
- if [ -x "${curlcmd}" ]; then
- curlcmd=${curlcmd}
- break
- fi
- done
- echo -ne " checking ${functionfile}...\c"
- function_file_diff=$(diff "${functionsdir}/${functionfile}" <(${curlcmd} -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}"))
- if [ "${function_file_diff}" != "" ]; then
- ${curlcmd} -s --fail -o "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}"
- local exitcode=$?
- if [ "${exitcode}" != "0" ]; then
- fn_print_fail_eol_nl
- rm -rf "${functionsdir}/${functionfile}"
- exitcode=2
- else
- echo -ne "\e[0;33mUPDATE\e[0m"
- rm -rf "${functionsdir}/${functionfile}"
- fn_update_function
- fi
- else
- fn_print_ok_eol_nl
- fi
- done
- fi
- fi
- if [ "${exitcode}" != "0" ]&&[ -n "${exitcode}" ]; then
- fn_print_fail "Updating functions"
- fn_script_log_fatal "Failure! Updating functions"
- else
- fn_print_ok "Updating functions"
- fn_script_log_pass "Success! Updating functions"
- exitcode=0
- fi
- echo -ne "\n"
- core_exit.sh
|