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=""
NEW_VER=""
ARCH=""
VDIS="64"
VDIS=''
ZIPFILE="/tmp/v2ray/v2ray.zip"
V2RAY_RUNNING=0
@ -98,29 +97,46 @@ colorEcho(){
echo -e "\033[${1}${@:2}\033[0m" 1>& 2
}
sysArch(){
ARCH=$(uname -m)
if [[ "$ARCH" == "i686" ]] || [[ "$ARCH" == "i386" ]]; then
VDIS="32"
elif [[ "$ARCH" == *"armv7"* ]] || [[ "$ARCH" == "armv6l" ]]; then
VDIS="arm"
elif [[ "$ARCH" == *"armv8"* ]] || [[ "$ARCH" == "aarch64" ]]; then
VDIS="arm64"
elif [[ "$ARCH" == *"mips64le"* ]]; then
VDIS="mips64le"
elif [[ "$ARCH" == *"mips64"* ]]; then
VDIS="mips64"
elif [[ "$ARCH" == *"mipsle"* ]]; then
VDIS="mipsle"
elif [[ "$ARCH" == *"mips"* ]]; then
VDIS="mips"
elif [[ "$ARCH" == *"s390x"* ]]; then
VDIS="s390x"
elif [[ "$ARCH" == "ppc64le" ]]; then
VDIS="ppc64le"
elif [[ "$ARCH" == "ppc64" ]]; then
VDIS="ppc64"
fi
archAffix(){
case "${1:-"$(uname -m)"}" in
i686|i386)
echo '32'
;;
x86_64|amd64)
echo '64'
;;
*armv7*|armv6l)
echo 'arm'
;;
*armv8*|aarch64)
echo 'arm64'
;;
*mips64le*)
echo 'mips64le'
;;
*mips64*)
echo 'mips64'
;;
*mipsle*)
echo 'mipsle'
;;
*mips*)
echo 'mips'
;;
*s390x*)
echo 's390x'
;;
ppc64le)
echo 'ppc64le'
;;
ppc64)
echo 'ppc64'
;;
*)
return 1
;;
esac
return 0
}
@ -408,7 +424,9 @@ main(){
[[ "$CHECK" == "1" ]] && checkUpdate && return
[[ "$REMOVE" == "1" ]] && remove && return
sysArch
local ARCH=$(uname -m)
VDIS="$(archAffix)"
# extract local file
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."