Merge pull request #1730 from 0xmohit/fix-install-script

fix install script when curl is not available
This commit is contained in:
sam boyer 2018-03-03 11:07:49 -05:00 коммит произвёл GitHub
Родитель 3d9e0bdd54 2c024c2d93
Коммит afd48a0604
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 8 добавлений и 7 удалений

Просмотреть файл

@ -23,14 +23,15 @@ downloadJSON() {
url="$2"
echo "Fetching $url.."
if type curl > /dev/null; then
if test -x "$(command -v curl)"; then
response=$(curl -s -L -w 'HTTPSTATUS:%{http_code}' -H 'Accept: application/json' "$url")
body=$(echo "$response" | sed -e 's/HTTPSTATUS\:.*//g')
code=$(echo "$response" | tr -d '\n' | sed -e 's/.*HTTPSTATUS://')
elif type wget > /dev/null; then
elif test -x "$(command -v wget)"; then
temp=$(mktemp)
body=$(wget -q --header='Accept: application/json' -O - --server-response --content-on-error "$url" 2> "$temp")
code=$(awk '/^ HTTP/{print $2}' < "$temp")
body=$(wget -q --header='Accept: application/json' -O - --server-response "$url" 2> "$temp")
code=$(awk '/^ HTTP/{print $2}' < "$temp" | tail -1)
rm "$temp"
else
echo "Neither curl nor wget was available to perform http requests."
exit 1
@ -48,10 +49,10 @@ downloadFile() {
destination="$2"
echo "Fetching $url.."
if type curl > /dev/null; then
if test -x "$(command -v curl)"; then
code=$(curl -s -w '%{http_code}' -L "$url" -o "$destination")
elif type wget > /dev/null; then
code=$(wget -q -O "$destination" --server-response "$url" 2>&1 | awk '/^ HTTP/{print $2}')
elif test -x "$(command -v wget)"; then
code=$(wget -q -O "$destination" --server-response "$url" 2>&1 | awk '/^ HTTP/{print $2}' | tail -1)
else
echo "Neither curl nor wget was available to perform http requests."
exit 1