mirror of https://github.com/XTLS/Xray-install
Alpine: refactor code related to architecture identification
parent
1a1f0f6d38
commit
b77ff248ac
|
@ -2,8 +2,34 @@
|
|||
|
||||
set -euxo pipefail
|
||||
|
||||
# Identify architecture
|
||||
case "$(arch -s)" in
|
||||
TMP_DIRECTORY="$(mktemp -d)/"
|
||||
ZIP_FILE="${TMP_DIRECTORY}Xray-linux-$MACHINE.zip"
|
||||
DOWNLOAD_LINK="https://github.com/XTLS/Xray-core/releases/latest/download/Xray-linux-$MACHINE.zip"
|
||||
|
||||
check_alpine() {
|
||||
if [ -f /etc/alpine-release ]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
check_if_running_as_root() {
|
||||
# If you want to run as another user, please modify $EUID to be owned by this user
|
||||
if [ "$(id -u)" -eq 0 ]; then
|
||||
return 0
|
||||
else
|
||||
echo "error: You must run this script as root!"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
identify_architecture() {
|
||||
if [ "$(uname)" != 'Linux' ]; then
|
||||
echo "error: This operating system is not supported."
|
||||
return 1
|
||||
fi
|
||||
case "$(uname -m)" in
|
||||
'i386' | 'i686')
|
||||
MACHINE='32'
|
||||
;;
|
||||
|
@ -32,6 +58,7 @@ case "$(arch -s)" in
|
|||
;;
|
||||
'mips64')
|
||||
MACHINE='mips64'
|
||||
lscpu | grep -q "Little Endian" && MACHINE='mips64le'
|
||||
;;
|
||||
'mips64le')
|
||||
MACHINE='mips64le'
|
||||
|
@ -50,28 +77,11 @@ case "$(arch -s)" in
|
|||
;;
|
||||
*)
|
||||
echo "error: The architecture is not supported."
|
||||
exit 1
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
|
||||
TMP_DIRECTORY="$(mktemp -d)/"
|
||||
ZIP_FILE="${TMP_DIRECTORY}Xray-linux-$MACHINE.zip"
|
||||
DOWNLOAD_LINK="https://github.com/XTLS/Xray-core/releases/latest/download/Xray-linux-$MACHINE.zip"
|
||||
|
||||
check_alpine() {
|
||||
if [ -f /etc/alpine-release ]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
check_if_running_as_root() {
|
||||
# If you want to run as another user, please modify $EUID to be owned by this user
|
||||
if [ "$(id -u)" -eq 0 ]; then
|
||||
return 0
|
||||
else
|
||||
echo "error: You must run this script as root!"
|
||||
if [ ! -f '/etc/os-release' ]; then
|
||||
echo "error: Don't use outdated Linux distributions."
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
@ -203,6 +213,7 @@ information() {
|
|||
main() {
|
||||
check_alpine || return 1
|
||||
check_if_running_as_root || return 1
|
||||
identify_architecture || return 1
|
||||
install_software
|
||||
download_xray
|
||||
verification_xray
|
||||
|
|
Loading…
Reference in New Issue