From cbfc9adb955ccb5a74ee51c5525be847a0650f1a Mon Sep 17 00:00:00 2001 From: v2ray Date: Fri, 12 Feb 2016 00:18:31 +0100 Subject: [PATCH] prefer command line flags over interaction --- release/install-release.sh | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/release/install-release.sh b/release/install-release.sh index 303b9ff5d..c1141078a 100755 --- a/release/install-release.sh +++ b/release/install-release.sh @@ -1,5 +1,31 @@ #!/bin/bash +while [[ $# > 0 ]] +do +key="$1" + +case $key in + -p|--proxy) + PROXY="$2" + shift # past argument + ;; + -h|--help) + HELP="1" + shift + ;; + *) + # unknown option + ;; +esac +shift # past argument or value +done + +if [[ "$HELP" == "1" ]]; then + echo "./install-release.sh [-p proxy]" + echo "To download through a proxy server, use -p socks5://127.0.0.1:1080 or -p http://127.0.0.1:3128 etc" + exit +fi + YUM_CMD=$(command -v yum) APT_CMD=$(command -v apt-get) @@ -33,15 +59,8 @@ DOWNLOAD_LINK="https://github.com/v2ray/v2ray-core/releases/download/${VER}/v2ra rm -rf /tmp/v2ray mkdir -p /tmp/v2ray -# Download release with proxy or not -echo 'Direct start downloading release,' -echo 'Or Enter a proxy URI for Downloading release.' -echo 'ex: socks5://127.0.0.1:1080' -echo 'ex: http://127.0.0.1:3128' -read PROXY_URI - -if [ -n "${PROXY_URI}" ]; then - curl -x ${PROXY_URI} -L -o "/tmp/v2ray/v2ray.zip" ${DOWNLOAD_LINK} +if [ -n "${PROXY}" ]; then + curl -x ${PROXY} -L -o "/tmp/v2ray/v2ray.zip" ${DOWNLOAD_LINK} else curl -L -o "/tmp/v2ray/v2ray.zip" ${DOWNLOAD_LINK} fi