From 400d487b6b6213ed48aef584d0ee867daea92b96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=9F=E9=85=8C=20=E9=B5=AC=E5=85=84?= Date: Mon, 22 Feb 2016 08:31:54 +0800 Subject: [PATCH] testing for downloader --- bash/bashrc/rbashrc | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/bash/bashrc/rbashrc b/bash/bashrc/rbashrc index e04ffd9..ffe0722 100644 --- a/bash/bashrc/rbashrc +++ b/bash/bashrc/rbashrc @@ -105,11 +105,25 @@ function __cacheDownload { __CFILE=$BASH_SDIR/$MLINK if [ ! -f "$__CFILE" ]; then - curl -s "$1" > "$__CFILE" + __download "$1" > "$__CFILE" __crypte "$__CFILE" fi } +function __download { + which curl 2>&1 > /dev/null + if [ $? -eq 0 ]; then + curl -s "$1" + return; + fi + + which wget 2>&1 > /dev/null + if [ $? -eq 0 ]; then + wget -qO- "$1" + return; + fi +} + function __uuid { local __out=$1 @@ -126,7 +140,7 @@ function rbash_upgrade { echo "Updating the .bashrc" __uuid TMPID TMPFILE=/tmp/$TMPID - curl -s "http://git.astropenguin.net/?p=utils.git;a=blob_plain;f=bash/bashrc/rbashrc;hb=HEAD" > $TMPFILE + __download "http://git.astropenguin.net/?p=utils.git;a=blob_plain;f=bash/bashrc/rbashrc;hb=HEAD" > $TMPFILE if [ -z "$1" ]; then MC_NAME=""