allow local binary

pull/168/head
v2ray 2016-05-27 17:20:31 +02:00
parent 46f76e55e5
commit 3c4c14c89c
1 changed files with 31 additions and 17 deletions

View File

@ -11,10 +11,16 @@ case $key in
;;
-h|--help)
HELP="1"
shift
;;
-f|--force)
FORCE="1"
;;
--version)
VERSION="$2"
shift
;;
--local)
LOCAL="$2"
shift
;;
*)
@ -71,14 +77,17 @@ if pgrep "v2ray" > /dev/null ; then
V2RAY_RUNNING=1
fi
if [ -n "$VERSION" ]; then
VER="$VERSION"
else
VER="$(curl -s https://api.github.com/repos/v2ray/v2ray-core/releases/latest | grep 'tag_name' | cut -d\" -f4)"
CUR_VER="$(/usr/bin/v2ray/v2ray -version | head -n 1 | cut -d " " -f2)"
if [[ "$VER" == "$CUR_VER" ]] && [[ "$FORCE" != "1" ]]; then
echo "Lastest version $VER is already installed. Exiting..."
exit
fi
fi
ARCH=$(uname -m)
VDIS="64"
@ -91,13 +100,15 @@ elif [[ "$ARCH" == *"armv8"* ]]; then
VDIS="arm64"
fi
DOWNLOAD_LINK="https://github.com/v2ray/v2ray-core/releases/download/${VER}/v2ray-linux-${VDIS}.zip"
rm -rf /tmp/v2ray
mkdir -p /tmp/v2ray
if [ -n "$LOCAL" ]; then
cp "$LOCAL" "/tmp/v2ray/v2ray.zip"
else
DOWNLOAD_LINK="https://github.com/v2ray/v2ray-core/releases/download/${VER}/v2ray-linux-${VDIS}.zip"
install_component "curl"
install_component "unzip"
if [ -n "${PROXY}" ]; then
echo "Downloading ${DOWNLOAD_LINK} via proxy ${PROXY}."
@ -106,6 +117,9 @@ else
echo "Downloading ${DOWNLOAD_LINK} directly."
curl -L -H "Cache-Control: no-cache" -o "/tmp/v2ray/v2ray.zip" ${DOWNLOAD_LINK}
fi
fi
install_component "unzip"
unzip "/tmp/v2ray/v2ray.zip" -d "/tmp/v2ray/"
# Create folder for V2Ray log.