mirror of
https://github.com/XTLS/Xray-install.git
synced 2024-11-23 23:51:26 +00:00
fix download xray
This commit is contained in:
parent
c93969886d
commit
242123f0b0
|
@ -124,7 +124,10 @@ check_if_running_as_root() {
|
|||
}
|
||||
|
||||
identify_the_operating_system_and_architecture() {
|
||||
if [[ "$(uname)" == 'Linux' ]]; then
|
||||
if [[ "$(uname)" != 'Linux' ]]; then
|
||||
echo "error: This operating system is not supported."
|
||||
exit 1
|
||||
fi
|
||||
case "$(uname -m)" in
|
||||
'i386' | 'i686')
|
||||
MACHINE='32'
|
||||
|
@ -218,10 +221,6 @@ identify_the_operating_system_and_architecture() {
|
|||
echo "error: The script does not support the package manager in this operating system."
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "error: This operating system is not supported."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
## Demo function for processing parameters
|
||||
|
@ -335,12 +334,12 @@ check_install_user() {
|
|||
INSTALL_USER='nobody'
|
||||
fi
|
||||
fi
|
||||
if ! id $INSTALL_USER > /dev/null 2>&1; then
|
||||
if ! id "$INSTALL_USER" > /dev/null 2>&1; then
|
||||
echo "the user '$INSTALL_USER' is not effective"
|
||||
exit 1
|
||||
fi
|
||||
INSTALL_USER_UID="$(id -u $INSTALL_USER)"
|
||||
INSTALL_USER_GID="$(id -g $INSTALL_USER)"
|
||||
INSTALL_USER_UID="$(id -u "$INSTALL_USER")"
|
||||
INSTALL_USER_GID="$(id -g "$INSTALL_USER")"
|
||||
}
|
||||
|
||||
install_software() {
|
||||
|
@ -405,9 +404,9 @@ get_latest_version() {
|
|||
exit 1
|
||||
fi
|
||||
local i
|
||||
for i in ${!releases_list[@]}
|
||||
for i in "${!releases_list[@]}"
|
||||
do
|
||||
releases_list[$i]="v${releases_list[$i]#v}"
|
||||
releases_list["$i"]="v${releases_list[$i]#v}"
|
||||
grep -q "https://github.com/XTLS/Xray-core/releases/download/${releases_list[$i]}/Xray-linux-$MACHINE.zip" "$tmp_file" && break
|
||||
done
|
||||
"rm" "$tmp_file"
|
||||
|
@ -419,25 +418,28 @@ version_gt() {
|
|||
}
|
||||
|
||||
download_xray() {
|
||||
DOWNLOAD_LINK="https://github.com/XTLS/Xray-core/releases/download/$INSTALL_VERSION/Xray-linux-$MACHINE.zip"
|
||||
DOWNLOAD_LINK="https://github.com/XTLS/Xray-core/releases/download/${INSTALL_VERSION}/Xray-linux-${MACHINE}.zip"
|
||||
echo "Downloading Xray archive: $DOWNLOAD_LINK"
|
||||
if ! curl -x "${PROXY}" -R -H 'Cache-Control: no-cache' -o "$ZIP_FILE" "$DOWNLOAD_LINK"; then
|
||||
if curl -f -x "${PROXY}" -R -H 'Cache-Control: no-cache' -o "$ZIP_FILE" "$DOWNLOAD_LINK"; then
|
||||
echo "ok."
|
||||
else
|
||||
echo 'error: Download failed! Please check your network or try again.'
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
echo "Downloading verification file for Xray archive: $DOWNLOAD_LINK.dgst"
|
||||
if ! curl -x "${PROXY}" -sSR -H 'Cache-Control: no-cache' -o "$ZIP_FILE.dgst" "$DOWNLOAD_LINK.dgst"; then
|
||||
echo "Downloading verification file for Xray archive: ${DOWNLOAD_LINK}.dgst"
|
||||
if curl -f -x "${PROXY}" -sSR -H 'Cache-Control: no-cache' -o "${ZIP_FILE}.dgst" "${DOWNLOAD_LINK}.dgst"; then
|
||||
echo "ok."
|
||||
else
|
||||
echo 'error: Download failed! Please check your network or try again.'
|
||||
return 1
|
||||
fi
|
||||
if [[ "$(cat "$ZIP_FILE".dgst)" == 'Not Found' ]]; then
|
||||
if grep 'Not Found' "${ZIP_FILE}.dgst"; then
|
||||
echo 'error: This version does not support verification. Please replace with another version.'
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Verification of Xray archive
|
||||
CHECKSUM=$(cat "$ZIP_FILE".dgst | awk -F '= ' '/256=/ {print $2}')
|
||||
CHECKSUM=$(awk -F '= ' '/256=/ {print $2}' "${ZIP_FILE}.dgst")
|
||||
LOCALSUM=$(sha256sum "$ZIP_FILE" | awk '{printf $1}')
|
||||
if [[ "$CHECKSUM" != "$LOCALSUM" ]]; then
|
||||
echo 'error: SHA256 check failed! Please check your network or try again.'
|
||||
|
@ -588,7 +590,7 @@ ExecStart=/usr/local/bin/xray run -config ${JSON_PATH}/%i.json" > \
|
|||
echo "${red}warning: ${green}Please make sure the configuration file path is correctly set.${reset}"
|
||||
systemd_cat_config /etc/systemd/system/xray.service
|
||||
# shellcheck disable=SC2154
|
||||
if [[ x"${check_all_service_files:0:1}" = x'y' ]]; then
|
||||
if [[ "${check_all_service_files:0:1}" = 'y' ]]; then
|
||||
echo
|
||||
echo
|
||||
systemd_cat_config /etc/systemd/system/xray@.service
|
||||
|
@ -695,7 +697,7 @@ install_geodata() {
|
|||
exit 1
|
||||
fi
|
||||
done
|
||||
cd - > /dev/null
|
||||
cd - > /dev/null || exit 1
|
||||
install -d "$DAT_PATH"
|
||||
install -m 644 "${dir_tmp}"/${file_dlc} "${DAT_PATH}"/${file_site}
|
||||
install -m 644 "${dir_tmp}"/${file_ip} "${DAT_PATH}"/${file_ip}
|
||||
|
@ -746,7 +748,7 @@ remove_xray() {
|
|||
echo 'error: Failed to remove Xray.'
|
||||
exit 1
|
||||
else
|
||||
for i in ${!delete_files[@]}
|
||||
for i in "${!delete_files[@]}"
|
||||
do
|
||||
echo "removed: ${delete_files[$i]}"
|
||||
done
|
||||
|
@ -886,7 +888,7 @@ main() {
|
|||
fi
|
||||
fi
|
||||
install_xray
|
||||
([[ "$N_UP_SERVICE" -eq '1' ]] && [[ -f '/etc/systemd/system/xray.service' ]]) || install_startup_service_file
|
||||
[[ "$N_UP_SERVICE" -eq '1' && -f '/etc/systemd/system/xray.service' ]] || install_startup_service_file
|
||||
echo 'installed: /usr/local/bin/xray'
|
||||
# If the file exists, the content output of installing or updating geoip.dat and geosite.dat will not be displayed
|
||||
if [[ "$GEODATA" -eq '1' ]]; then
|
||||
|
|
Loading…
Reference in a new issue