1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-09-27 22:36:12 -04:00

Merge pull request #1037 from sunshineplan/2

install-release.sh检查版本功能更新
This commit is contained in:
DarienRaymond 2018-04-12 15:19:32 +02:00 committed by GitHub
commit bc2d2ae866
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -161,21 +161,24 @@ extract(){
}
# 1: new V2Ray. 0: no
# 1: new V2Ray. 0: no. 2: not installed. 3: check failed. 4: don't check.
getVersion(){
if [[ -n "$VERSION" ]]; then
NEW_VER="$VERSION"
return 1
return 4
else
CUR_VER=`/usr/bin/v2ray/v2ray -version 2>/dev/null | head -n 1 | cut -d " " -f2`
VER=`/usr/bin/v2ray/v2ray -version 2>/dev/null`
RETVAL="$?"
CUR_VER=`echo $VER | head -n 1 | cut -d " " -f2`
TAG_URL="https://api.github.com/repos/v2ray/v2ray-core/releases/latest"
NEW_VER=`curl ${PROXY} -s ${TAG_URL} --connect-timeout 10| grep 'tag_name' | cut -d\" -f4`
if [[ $? -ne 0 ]] || [[ $NEW_VER == "" ]]; then
colorEcho ${RED} "Network error! Please check your network or try again."
exit
return 3
elif [[ $RETVAL -ne 0 ]];then
return 2
elif [[ "$NEW_VER" != "$CUR_VER" ]];then
return 1
return 1
fi
return 0
fi
@ -288,7 +291,7 @@ Help(){
echo " -h, --help Show help"
echo " -p, --proxy To download through a proxy server, use -p socks5://127.0.0.1:1080 or -p http://127.0.0.1:3128 etc"
echo " -f, --force Force install"
echo " --version Install a particular version"
echo " --version Install a particular version, use --version v3.15"
echo " -l, --local Install from a local file"
echo " --remove Remove installed V2Ray"
echo " -c, --check Check for update"
@ -346,22 +349,26 @@ remove(){
}
checkUpdate(){
echo "Checking for update."
getVersion
if [[ $? -eq 1 ]]; then
colorEcho ${GREEN} "Found new version ${NEW_VER} for V2Ray."
exit
else
colorEcho ${GREEN} "No new version."
exit
fi
echo "Checking for update."
VERSION=""
getVersion
RETVAL="$?"
if [[ $RETVAL -eq 1 ]]; then
colorEcho ${GREEN} "Found new version ${NEW_VER} for V2Ray.(Current version:$CUR_VER)"
elif [[ $RETVAL -eq 0 ]]; then
colorEcho ${GREEN} "No new version. Current version is ${NEW_VER}."
elif [[ $RETVAL -eq 2 ]]; then
colorEcho ${RED} "No V2Ray installed."
colorEcho ${GREEN} "The newest version for V2Ray is ${NEW_VER}."
fi
return 0
}
main(){
#helping information
[[ "$HELP" == "1" ]] && Help
[[ "$CHECK" == "1" ]] && checkUpdate
[[ "$REMOVE" == "1" ]] && remove
[[ "$CHECK" == "1" ]] && checkUpdate && return
sysArch
# extract local file
@ -385,9 +392,14 @@ main(){
# download via network and extract
installSoftware "curl"
getVersion
if [[ $? == 0 ]] && [[ "$FORCE" != "1" ]]; then
RETVAL="$?"
if [[ $RETVAL == 0 ]] && [[ "$FORCE" != "1" ]]; then
colorEcho ${GREEN} "Latest version ${NEW_VER} is already installed."
exit
return
elif [[ $RETVAL == 3 ]]; then
return 3
elif [[ $RETVAL == 1 ]]; then
colorEcho ${GREEN} "Found new version ${NEW_VER} for V2Ray.(Current version:$CUR_VER)"
else
colorEcho ${BLUE} "Installing V2Ray ${NEW_VER} on ${ARCH}"
downloadV2Ray