Unalias crucial functions when issuing them

for preventing user-custom aliases interupt script
pull/81/head
IceCodeNew 2020-09-05 10:18:10 +08:00
parent 55fe32f505
commit 5d471592fd
1 changed files with 16 additions and 16 deletions

View File

@ -254,13 +254,13 @@ get_version() {
TMP_FILE="$(mktemp)" TMP_FILE="$(mktemp)"
install_software curl install_software curl
# DO NOT QUOTE THESE `${PROXY}` VARIABLES! # DO NOT QUOTE THESE `${PROXY}` VARIABLES!
if ! curl ${PROXY} -o "$TMP_FILE" 'https://api.github.com/repos/v2fly/v2ray-core/releases/latest'; then if ! "curl" ${PROXY} -o "$TMP_FILE" 'https://api.github.com/repos/v2fly/v2ray-core/releases/latest'; then
rm "$TMP_FILE" "rm" "$TMP_FILE"
echo 'error: Failed to get release list, please check your network.' echo 'error: Failed to get release list, please check your network.'
exit 1 exit 1
fi fi
RELEASE_LATEST="$(sed 'y/,/\n/' "$TMP_FILE" | grep 'tag_name' | awk -F '"' '{print $4}')" RELEASE_LATEST="$(sed 'y/,/\n/' "$TMP_FILE" | grep 'tag_name' | awk -F '"' '{print $4}')"
rm "$TMP_FILE" "rm" "$TMP_FILE"
RELEASE_VERSION="$(version_number "$RELEASE_LATEST")" RELEASE_VERSION="$(version_number "$RELEASE_LATEST")"
# Compare V2Ray version numbers # Compare V2Ray version numbers
if [[ "$RELEASE_VERSION" != "$CURRENT_VERSION" ]]; then if [[ "$RELEASE_VERSION" != "$CURRENT_VERSION" ]]; then
@ -299,15 +299,15 @@ get_version() {
} }
download_v2ray() { download_v2ray() {
mkdir "$TMP_DIRECTORY" "mkdir" -p "$TMP_DIRECTORY"
DOWNLOAD_LINK="https://github.com/v2fly/v2ray-core/releases/download/$RELEASE_VERSION/v2ray-linux-$MACHINE.zip" DOWNLOAD_LINK="https://github.com/v2fly/v2ray-core/releases/download/$RELEASE_VERSION/v2ray-linux-$MACHINE.zip"
echo "Downloading V2Ray archive: $DOWNLOAD_LINK" echo "Downloading V2Ray archive: $DOWNLOAD_LINK"
if ! curl ${PROXY} -L -H 'Cache-Control: no-cache' -o "$ZIP_FILE" "$DOWNLOAD_LINK"; then if ! "curl" ${PROXY} -L -H 'Cache-Control: no-cache' -o "$ZIP_FILE" "$DOWNLOAD_LINK"; then
echo 'error: Download failed! Please check your network or try again.' echo 'error: Download failed! Please check your network or try again.'
return 1 return 1
fi fi
echo "Downloading verification file for V2Ray archive: $DOWNLOAD_LINK.dgst" echo "Downloading verification file for V2Ray archive: $DOWNLOAD_LINK.dgst"
if ! curl ${PROXY} -L -H 'Cache-Control: no-cache' -o "$ZIP_FILE.dgst" "$DOWNLOAD_LINK.dgst"; then if ! "curl" ${PROXY} -L -H 'Cache-Control: no-cache' -o "$ZIP_FILE.dgst" "$DOWNLOAD_LINK.dgst"; then
echo 'error: Download failed! Please check your network or try again.' echo 'error: Download failed! Please check your network or try again.'
return 1 return 1
fi fi
@ -330,7 +330,7 @@ download_v2ray() {
decompression() { decompression() {
if ! unzip -q "$1" -d "$TMP_DIRECTORY"; then if ! unzip -q "$1" -d "$TMP_DIRECTORY"; then
echo 'error: V2Ray decompression failed.' echo 'error: V2Ray decompression failed.'
rm -r "$TMP_DIRECTORY" "rm" -r "$TMP_DIRECTORY"
echo "removed: $TMP_DIRECTORY" echo "removed: $TMP_DIRECTORY"
exit 1 exit 1
fi fi
@ -381,7 +381,7 @@ install_v2ray() {
install_startup_service_file() { install_startup_service_file() {
if [[ ! -f '/etc/systemd/system/v2ray.service' ]]; then if [[ ! -f '/etc/systemd/system/v2ray.service' ]]; then
mkdir "${TMP_DIRECTORY}/systemd/system/" "mkdir" -p "${TMP_DIRECTORY}/systemd/system/"
install_software curl install_software curl
cat > "${TMP_DIRECTORY}/systemd/system/v2ray.service" <<-EOF cat > "${TMP_DIRECTORY}/systemd/system/v2ray.service" <<-EOF
[Unit] [Unit]
@ -473,11 +473,11 @@ remove_v2ray() {
stop_v2ray stop_v2ray
fi fi
NAME="$1" NAME="$1"
rm /usr/local/bin/v2ray "rm" /usr/local/bin/v2ray
rm /usr/local/bin/v2ctl "rm" /usr/local/bin/v2ctl
rm -r "$DAT_PATH" "rm" -r "$DAT_PATH"
rm /etc/systemd/system/v2ray.service "rm" /etc/systemd/system/v2ray.service
rm /etc/systemd/system/v2ray@.service "rm" /etc/systemd/system/v2ray@.service
if [[ "$?" -ne '0' ]]; then if [[ "$?" -ne '0' ]]; then
echo 'error: Failed to remove V2Ray.' echo 'error: Failed to remove V2Ray.'
exit 1 exit 1
@ -534,7 +534,7 @@ main() {
echo -n 'warn: Please make sure the file is valid because we cannot confirm it. (Press any key) ...' echo -n 'warn: Please make sure the file is valid because we cannot confirm it. (Press any key) ...'
read read
install_software unzip install_software unzip
mkdir "$TMP_DIRECTORY" "mkdir" -p "$TMP_DIRECTORY"
decompression "$LOCAL_FILE" decompression "$LOCAL_FILE"
else else
# Normal way # Normal way
@ -544,7 +544,7 @@ main() {
echo "info: Installing V2Ray $RELEASE_VERSION for $(uname -m)" echo "info: Installing V2Ray $RELEASE_VERSION for $(uname -m)"
download_v2ray download_v2ray
if [[ "$?" -eq '1' ]]; then if [[ "$?" -eq '1' ]]; then
rm -r "$TMP_DIRECTORY" "rm" -r "$TMP_DIRECTORY"
echo "removed: $TMP_DIRECTORY" echo "removed: $TMP_DIRECTORY"
exit 0 exit 0
fi fi
@ -596,7 +596,7 @@ main() {
echo 'installed: /etc/systemd/system/v2ray.service' echo 'installed: /etc/systemd/system/v2ray.service'
echo 'installed: /etc/systemd/system/v2ray@.service' echo 'installed: /etc/systemd/system/v2ray@.service'
fi fi
rm -r "$TMP_DIRECTORY" "rm" -r "$TMP_DIRECTORY"
echo "removed: $TMP_DIRECTORY" echo "removed: $TMP_DIRECTORY"
if [[ "$LOCAL_INSTALL" -eq '1' ]]; then if [[ "$LOCAL_INSTALL" -eq '1' ]]; then
get_version get_version