Enable deployment_scripts/config to use wget or curl

This commit is contained in:
Mike Salvatore 2020-12-08 12:25:41 -05:00
parent b84d1f1708
commit c807104a38
1 changed files with 15 additions and 3 deletions

View File

@ -4,10 +4,22 @@ export MONKEY_FOLDER_NAME="infection_monkey"
# Url of public git repository that contains monkey's source code # Url of public git repository that contains monkey's source code
export MONKEY_GIT_URL="https://github.com/guardicore/monkey" export MONKEY_GIT_URL="https://github.com/guardicore/monkey"
exists() {
command -v "$1" >/dev/null 2>&1
}
get_latest_release() { get_latest_release() {
curl --silent "https://api.github.com/repos/$1/releases/latest" | # Get latest release from GitHub API RELEASE_URL="https://api.github.com/repos/$1/releases/latest"
grep '"tag_name":' | # Get tag line
sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value if exists wget; then
RELEASE_INFO=$(wget --quiet -O - "$RELEASE_URL") # Get latest release from GitHub API
else
RELEASE_INFO=$(curl --silent "$RELEASE_URL") # Get latest release from GitHub API
fi
echo "$RELEASE_INFO" |
grep '"tag_name":' | # Get tag line
sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value
} }
MONKEY_LATEST_RELEASE=$(get_latest_release "guardicore/monkey") MONKEY_LATEST_RELEASE=$(get_latest_release "guardicore/monkey")