From 71a79ed57f54106e995084b5629ced3ec0ebb311 Mon Sep 17 00:00:00 2001 From: Lukas Macura Date: Mon, 5 Dec 2016 12:03:13 +0100 Subject: [PATCH] Added possibility to use wget --- README.md | 8 ++++++++ install.sh | 19 +++++++++++++------ lib/zaf.lib.sh | 12 +++++++++--- zaf | 2 ++ 4 files changed, 32 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 7bd513c..fe74007 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,14 @@ You need to be root and you must have curl installed on your system. Depending o ``` curl -k https://raw.githubusercontent.com/limosek/zaf/master/install.sh | sh ``` +If you have only wget installed: +``` +wget --no-check-certificate -O - https://raw.githubusercontent.com/limosek/zaf/master/install.sh | sh +``` +If you do not have https support (like openwrt) +``` +wget -O - http://github.macura.cz/zaf/install.sh| ZAF_RAW_URL=http://github.macura.cz/zaf/install.sh ZAF_REPO_URL=http://github.macura.cz/zaf-plugins/ sh +``` ### Install options and autoconfiguration General parameters for install.sh on any system (simplest way how to install) diff --git a/install.sh b/install.sh index eda664e..ed0993b 100755 --- a/install.sh +++ b/install.sh @@ -5,6 +5,9 @@ if [ -z "$ZAF_URL" ]; then # Runing as standalone install.sh. We have to download rest of files first. ZAF_URL="https://github.com/limosek/zaf/" fi +if [ -z "$ZAF_RAW_URL" ]; then + ZAF_RAW_URL="https://raw.githubusercontent.com/limosek/zaf" +fi [ -z "$ZAF_GITBRANCH" ] && ZAF_GITBRANCH=master @@ -12,8 +15,12 @@ fi # Lite version of zaf_fetch_url, full version will be loaded later zaf_fetch_url(){ - echo curl -f -k -s -L -o - "$1" >&2; - curl -f -k -s -L -o - "$1" + if zaf_which curl >/dev/null 2>/dev/null; then + echo curl -f -k -s -L -o - "$1" >&2; + curl -f -k -s -L -o - "$1" + else + wget --no-check-certificate -O - "$1" + fi } # Lite version of zaf_which, full version will be loaded later @@ -401,17 +408,17 @@ zaf_postconfigure() { if ! [ -f README.md ]; then # Hardcoded variables ZAF_VERSION="1.3" - ZAF_URL="https://github.com/limosek/zaf" - ZAF_RAW_URL="https://raw.githubusercontent.com/limosek/zaf" export ZAF_TMP_DIR="/tmp/zaf-installer" export ZAF_DIR="$ZAF_TMP_DIR/zaf" if [ -n "$ZAF_PROXY" ]; then export ALL_PROXY="$ZAF_PROXY" + export http_proxy="$ZAF_PROXY" + export https_proxy="$ZAF_PROXY" fi mkdir -p $ZAF_TMP_DIR - if ! zaf_which curl >/dev/null; + if ! zaf_which curl >/dev/null && ! zaf_which wget >/dev/null; then - zaf_err "Curl not found. Cannot continue. Please install it." + zaf_err "Curl or wget not found. Cannot continue. Please install it." fi echo "Installing from url $url..." [ -z "$*" ] && auto=auto diff --git a/lib/zaf.lib.sh b/lib/zaf.lib.sh index eda248e..20e9a56 100644 --- a/lib/zaf.lib.sh +++ b/lib/zaf.lib.sh @@ -102,9 +102,15 @@ zaf_fetch_url() { case $scheme in http|https|ftp|file) [ "$scheme" != "file" ] && [ -n "$ZAF_OFFLINE" ] && zaf_err "Cannot download $1 in offline mode!" - [ "${ZAF_CURL_INSECURE}" = "1" ] && insecure="-k" - zaf_dbg curl $insecure -f -s -L -o - $1 - curl $insecure -f -s -L -o - "$1" | zaf_tocache_stdin "$1" 120 + if zaf_which curl >/dev/null 2>/dev/null; then + [ "${ZAF_CURL_INSECURE}" = "1" ] && insecure="-k" + zaf_dbg curl $insecure -f -s -L -o - $1 + curl $insecure -f -s -L -o - "$1" | zaf_tocache_stdin "$1" 120 + else + [ "${ZAF_CURL_INSECURE}" = "1" ] && insecure="--no-check-certificate" + zaf_dbg wget $insecure -O - $1 + wget $insecure -O - "$1" | zaf_tocache_stdin "$1" 120 + fi ;; esac } diff --git a/zaf b/zaf index f28db62..d662172 100755 --- a/zaf +++ b/zaf @@ -27,6 +27,8 @@ fi if [ -n "$ZAF_PROXY" ]; then export ALL_PROXY="$ZAF_PROXY" + export http_proxy="$ZAF_PROXY" + export https_proxy="$ZAF_PROXY" fi if [ -f ./lib/zaf.lib.sh ]; then