Browse Source

minor stuff

pull/3164/head
Daniel Gibbs 5 years ago
parent
commit
595b72e7f8
  1. 26
      lgsm/functions/core_dl.sh

26
lgsm/functions/core_dl.sh

@ -447,11 +447,11 @@ fn_update_function(){
} }
# Function to download latest github release # Function to download latest github release.
# $1 github user / organisation # $1 GitHub user / organisation.
# $2 repo name # $2 Repo name.
# $3 destination for download # $3 Destination for download.
# $4 search string in releases (needed if there are more files that can be downloaded from the release pages) # $4 Search string in releases (needed if there are more files that can be downloaded from the release pages).
fn_dl_latest_release_github(){ fn_dl_latest_release_github(){
local githubreleaseuser="${1}" local githubreleaseuser="${1}"
local githubreleaserepo="${2}" local githubreleaserepo="${2}"
@ -459,29 +459,29 @@ fn_dl_latest_release_github(){
local githubreleasesearch="${4}" local githubreleasesearch="${4}"
local githublatestreleaseurl="https://api.github.com/repos/${githubreleaseuser}/${githubreleaserepo}/releases/latest" local githublatestreleaseurl="https://api.github.com/repos/${githubreleaseuser}/${githubreleaserepo}/releases/latest"
# get last github release # Get last github release.
# if no search for the release filename is set, just get the first file from the latest release # If no search for the release filename is set, just get the first file from the latest release.
if [ -z "${githubreleasesearch}" ]; then if [ -z "${githubreleasesearch}" ]; then
githubreleaseassets=$(curl -s "${githublatestreleaseurl}" | jq '[ .assets[] ]') githubreleaseassets=$(curl -s "${githublatestreleaseurl}" | jq '[ .assets[] ]')
else else
githubreleaseassets=$(curl -s "${githublatestreleaseurl}" | jq "[ .assets[]|select(.browser_download_url | contains(\"${githubreleasesearch}\")) ]") githubreleaseassets=$(curl -s "${githublatestreleaseurl}" | jq "[ .assets[]|select(.browser_download_url | contains(\"${githubreleasesearch}\")) ]")
fi fi
# check how many releases we got from the api and exit if we have more then one # Check how many releases we got from the api and exit if we have more then one.
if [ "$(echo -e "${githubreleaseassets}" | jq '. | length')" -gt 1 ]; then if [ "$(echo -e "${githubreleaseassets}" | jq '. | length')" -gt 1 ]; then
fn_print_fatal_nl "Found more than one release to download - Please report this to the github issue tracker" fn_print_fatal_nl "Found more than one release to download - Please report this to the LinuxGSM issue tracker"
fn_script_log_fatal "Found more than one release to download - Please report this to the github issue tracker" fn_script_log_fatal "Found more than one release to download - Please report this to the LinuxGSM issue tracker"
else else
# set variables for download via fn_fetch_file # Set variables for download via fn_fetch_file.
githubreleasefilename=$(echo -e "${githubreleaseassets}" | jq -r '.[]name') githubreleasefilename=$(echo -e "${githubreleaseassets}" | jq -r '.[]name')
githubreleasedownloadlink=$(echo -e "${githubreleaseassets}" | jq -r '.[]browser_download_url') githubreleasedownloadlink=$(echo -e "${githubreleaseassets}" | jq -r '.[]browser_download_url')
# error if no version is there # Error if no version is there.
if [ -z "${githubreleasefilename}" ]; then if [ -z "${githubreleasefilename}" ]; then
fn_print_fail_nl "Cannot get version from GitHub API for ${githubreleaseuser}/${githubreleaserepo}" fn_print_fail_nl "Cannot get version from GitHub API for ${githubreleaseuser}/${githubreleaserepo}"
fn_script_log_fatal "Cannot get version from GitHub API for ${githubreleaseuser}/${githubreleaserepo}" fn_script_log_fatal "Cannot get version from GitHub API for ${githubreleaseuser}/${githubreleaserepo}"
else else
# fetch file from the remote location from the existing function to the ${tmpdir} for now # Fetch file from the remote location from the existing function to the ${tmpdir} for now.
fn_fetch_file "${githubreleasedownloadlink}" "" "${githubreleasefilename}" "" "${githubreleasedownloadpath}" "${githubreleasefilename}" fn_fetch_file "${githubreleasedownloadlink}" "" "${githubreleasefilename}" "" "${githubreleasedownloadpath}" "${githubreleasefilename}"
fi fi
fi fi

Loading…
Cancel
Save