1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-22 01:57:12 -05:00

refactor: Remove side effect from sysArch()

This commit is contained in:
xymopen 2020-01-08 10:40:48 +08:00 committed by kslr
parent 4ae653e884
commit fa657b8681

View File

@ -25,8 +25,7 @@ ERROR_IF_UPTODATE=''
CUR_VER="" CUR_VER=""
NEW_VER="" NEW_VER=""
ARCH="" VDIS=''
VDIS="64"
ZIPFILE="/tmp/v2ray/v2ray.zip" ZIPFILE="/tmp/v2ray/v2ray.zip"
V2RAY_RUNNING=0 V2RAY_RUNNING=0
@ -98,30 +97,47 @@ colorEcho(){
echo -e "\033[${1}${@:2}\033[0m" 1>& 2 echo -e "\033[${1}${@:2}\033[0m" 1>& 2
} }
sysArch(){ archAffix(){
ARCH=$(uname -m) case "${1:-"$(uname -m)"}" in
if [[ "$ARCH" == "i686" ]] || [[ "$ARCH" == "i386" ]]; then i686|i386)
VDIS="32" echo '32'
elif [[ "$ARCH" == *"armv7"* ]] || [[ "$ARCH" == "armv6l" ]]; then ;;
VDIS="arm" x86_64|amd64)
elif [[ "$ARCH" == *"armv8"* ]] || [[ "$ARCH" == "aarch64" ]]; then echo '64'
VDIS="arm64" ;;
elif [[ "$ARCH" == *"mips64le"* ]]; then *armv7*|armv6l)
VDIS="mips64le" echo 'arm'
elif [[ "$ARCH" == *"mips64"* ]]; then ;;
VDIS="mips64" *armv8*|aarch64)
elif [[ "$ARCH" == *"mipsle"* ]]; then echo 'arm64'
VDIS="mipsle" ;;
elif [[ "$ARCH" == *"mips"* ]]; then *mips64le*)
VDIS="mips" echo 'mips64le'
elif [[ "$ARCH" == *"s390x"* ]]; then ;;
VDIS="s390x" *mips64*)
elif [[ "$ARCH" == "ppc64le" ]]; then echo 'mips64'
VDIS="ppc64le" ;;
elif [[ "$ARCH" == "ppc64" ]]; then *mipsle*)
VDIS="ppc64" echo 'mipsle'
fi ;;
return 0 *mips*)
echo 'mips'
;;
*s390x*)
echo 's390x'
;;
ppc64le)
echo 'ppc64le'
;;
ppc64)
echo 'ppc64'
;;
*)
return 1
;;
esac
return 0
} }
downloadV2Ray(){ downloadV2Ray(){
@ -408,7 +424,9 @@ main(){
[[ "$CHECK" == "1" ]] && checkUpdate && return [[ "$CHECK" == "1" ]] && checkUpdate && return
[[ "$REMOVE" == "1" ]] && remove && return [[ "$REMOVE" == "1" ]] && remove && return
sysArch local ARCH=$(uname -m)
VDIS="$(archAffix)"
# extract local file # extract local file
if [[ $LOCAL_INSTALL -eq 1 ]]; then if [[ $LOCAL_INSTALL -eq 1 ]]; then
colorEcho ${YELLOW} "Installing V2Ray via local file. Please make sure the file is a valid V2Ray package, as we are not able to determine that." colorEcho ${YELLOW} "Installing V2Ray via local file. Please make sure the file is a valid V2Ray package, as we are not able to determine that."