Skip to content

Commit

Permalink
Merge pull request #170 from xiagw/remove-useless-version-number
Browse files Browse the repository at this point in the history
remove useless function version_number
  • Loading branch information
IceCodeNew authored Oct 15, 2020
2 parents 7001a6d + ab7cc47 commit bfd16b9
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions install-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -205,29 +205,18 @@ install_software() {
fi
}

version_number() {
case "$1" in
'v'*)
echo "$1"
;;
*)
echo "v$1"
;;
esac
}

get_version() {
# 0: Install or update V2Ray.
# 1: Installed or no new version of V2Ray.
# 2: Install the specified version of V2Ray.
if [[ -n "$VERSION" ]]; then
RELEASE_VERSION="$(version_number "$VERSION")"
RELEASE_VERSION="v${VERSION#v}"
return 2
fi
# Determine the version number for V2Ray installed from a local file
if [[ -f '/usr/local/bin/v2ray' ]]; then
VERSION="$(/usr/local/bin/v2ray -version)"
CURRENT_VERSION="$(version_number "$(echo "$VERSION" | awk 'NR==1 {print $2}')")"
VERSION="$(/usr/local/bin/v2ray -version | awk 'NR==1 {print $2}')"
CURRENT_VERSION="v${VERSION#v}"
if [[ "$LOCAL_INSTALL" -eq '1' ]]; then
RELEASE_VERSION="$CURRENT_VERSION"
return
Expand All @@ -242,7 +231,7 @@ get_version() {
fi
RELEASE_LATEST="$(sed 'y/,/\n/' "$TMP_FILE" | grep 'tag_name' | awk -F '"' '{print $4}')"
"rm" "$TMP_FILE"
RELEASE_VERSION="$(version_number "$RELEASE_LATEST")"
RELEASE_VERSION="v${RELEASE_LATEST#v}"
# Compare V2Ray version numbers
if [[ "$RELEASE_VERSION" != "$CURRENT_VERSION" ]]; then
RELEASE_VERSIONSION_NUMBER="${RELEASE_VERSION#v}"
Expand Down

0 comments on commit bfd16b9

Please sign in to comment.