Skip to content

fix(update-lgsm): incorrect wdir sometimes #4140

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 40 additions & 38 deletions lgsm/functions/command_update_linuxgsm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -182,49 +182,51 @@ fi
# Check and update modules.
if [ -n "${functionsdir}" ]; then
if [ -d "${functionsdir}" ]; then
cd "${functionsdir}" || exit
for functionfile in *; do
# check if module exists in the repo and remove if missing.
# commonly used if module names change.
echo -en "checking ${remotereponame} module ${functionfile}...\c"
github_file_url_dir="lgsm/functions"
if [ "${remotereponame}" == "GitHub" ]; then
curl --connect-timeout 10 -IsfL "https://github.com/raw/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}" 1> /dev/null
else
curl --connect-timeout 10 -IsfL "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/${github_file_url_dir}/${functionfile}" 1> /dev/null
fi
if [ $? != 0 ]; then
fn_print_error_eol_nl
fn_script_log_error "Checking ${remotereponame} module ${functionfile}"
echo -en "removing module ${functionfile}...\c"
if ! rm -f "${functionfile:?}"; then
fn_print_fail_eol_nl
fn_script_log_fatal "Removing module ${functionfile}"
core_exit.sh
else
fn_print_ok_eol_nl
fn_script_log_pass "Removing module ${functionfile}"
fi
else
# compare file
(
cd "${functionsdir}" || exit
for functionfile in *; do
# check if module exists in the repo and remove if missing.
# commonly used if module names change.
echo -en "checking ${remotereponame} module ${functionfile}...\c"
github_file_url_dir="lgsm/functions"
if [ "${remotereponame}" == "GitHub" ]; then
function_file_diff=$(diff "${functionsdir}/${functionfile}" <(curl --connect-timeout 10 -s "https://github.com/raw/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}"))
curl --connect-timeout 10 -IsfL "https://github.com/raw/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}" 1> /dev/null
else
function_file_diff=$(diff "${functionsdir}/${functionfile}" <(curl --connect-timeout 10 -s "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/${github_file_url_dir}/${functionfile}"))
curl --connect-timeout 10 -IsfL "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/${github_file_url_dir}/${functionfile}" 1> /dev/null
fi

# results
if [ "${function_file_diff}" != "" ]; then
fn_print_update_eol_nl
fn_script_log_update "Checking ${remotereponame} module ${functionfile}"
rm -rf "${functionsdir:?}/${functionfile}"
fn_update_function
if [ $? != 0 ]; then
fn_print_error_eol_nl
fn_script_log_error "Checking ${remotereponame} module ${functionfile}"
echo -en "removing module ${functionfile}...\c"
if ! rm -f "${functionfile:?}"; then
fn_print_fail_eol_nl
fn_script_log_fatal "Removing module ${functionfile}"
core_exit.sh
else
fn_print_ok_eol_nl
fn_script_log_pass "Removing module ${functionfile}"
fi
else
fn_print_ok_eol_nl
fn_script_log_pass "Checking ${remotereponame} module ${functionfile}"
# compare file
if [ "${remotereponame}" == "GitHub" ]; then
function_file_diff=$(diff "${functionsdir}/${functionfile}" <(curl --connect-timeout 10 -s "https://github.com/raw/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}"))
else
function_file_diff=$(diff "${functionsdir}/${functionfile}" <(curl --connect-timeout 10 -s "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/${github_file_url_dir}/${functionfile}"))
fi

# results
if [ "${function_file_diff}" != "" ]; then
fn_print_update_eol_nl
fn_script_log_update "Checking ${remotereponame} module ${functionfile}"
rm -rf "${functionsdir:?}/${functionfile}"
fn_update_function
else
fn_print_ok_eol_nl
fn_script_log_pass "Checking ${remotereponame} module ${functionfile}"
fi
fi
fi
done
done
)
fi
fi

Expand Down