From 62d33830da66d1684062b6f9d74333c9a00bcb06 Mon Sep 17 00:00:00 2001 From: IceCodeNew <32576256+IceCodeNew@users.noreply.github.com> Date: Fri, 25 Sep 2020 16:43:55 +0800 Subject: [PATCH 1/3] install package which provide `tput`; change function `install_software` --- install-release.sh | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/install-release.sh b/install-release.sh index 460bd89..cb8ea10 100644 --- a/install-release.sh +++ b/install-release.sh @@ -23,10 +23,6 @@ JSON_PATH=${JSON_PATH:-/usr/local/etc/v2ray} # Set this variable only if you are starting v2ray with multiple configuration files: # export JSONS_PATH='/usr/local/etc/v2ray' -red=$(tput setaf 1) -green=$(tput setaf 2) -reset=$(tput sgr0) - curl() { $(type -P curl) -L -q --retry 5 --retry-delay 10 --retry-max-time 60 "$@" } @@ -107,18 +103,23 @@ identify_the_operating_system_and_architecture() { if [[ "$(type -P apt)" ]]; then PACKAGE_MANAGEMENT_INSTALL='apt install -y --no-install-recommends' PACKAGE_MANAGEMENT_REMOVE='apt purge -y --auto-remove' + package_provide_tput='ncurses-bin' elif [[ "$(type -P dnf)" ]]; then PACKAGE_MANAGEMENT_INSTALL='dnf install -y' PACKAGE_MANAGEMENT_REMOVE='dnf remove -y' + package_provide_tput='ncurses' elif [[ "$(type -P yum)" ]]; then PACKAGE_MANAGEMENT_INSTALL='yum install -y' PACKAGE_MANAGEMENT_REMOVE='yum remove -y' + package_provide_tput='ncurses' elif [[ "$(type -P zypper)" ]]; then PACKAGE_MANAGEMENT_INSTALL='zypper install -y --no-recommends' PACKAGE_MANAGEMENT_REMOVE='zypper remove -yu' + package_provide_tput='ncurses-utils' elif [[ "$(type -P pacman)" ]]; then PACKAGE_MANAGEMENT_INSTALL='pacman -Syu --noconfirm' PACKAGE_MANAGEMENT_REMOVE='pacman -Rsun --noconfirm' + package_provide_tput='ncurses' else echo "error: The script does not support the package manager in this operating system." exit 1 @@ -179,12 +180,13 @@ judgment_parameters() { } install_software() { - COMPONENT="$1" - type -P "$COMPONENT" > /dev/null 2>&1 && return - if ${PACKAGE_MANAGEMENT_INSTALL} "$COMPONENT"; then - echo "info: $COMPONENT is installed." + package_name="$1" + file_to_detect="$2" + type -P "$file_to_detect" > /dev/null 2>&1 && return + if ${PACKAGE_MANAGEMENT_INSTALL} "$package_name"; then + echo "info: $package_name is installed." else - echo "error: Installation of $COMPONENT failed, please check your network." + echo "error: Installation of $package_name failed, please check your network." exit 1 fi } @@ -483,6 +485,11 @@ main() { identify_the_operating_system_and_architecture judgment_parameters "$@" + install_software "$package_provide_tput" 'tput' + red=$(tput setaf 1) + green=$(tput setaf 2) + reset=$(tput sgr0) + # Parameter information [[ "$HELP" -eq '1' ]] && show_help [[ "$CHECK" -eq '1' ]] && check_update @@ -497,11 +504,11 @@ main() { echo 'warn: Install V2Ray from a local file, but still need to make sure the network is available.' echo -n 'warn: Please make sure the file is valid because we cannot confirm it. (Press any key) ...' read - install_software unzip + install_software 'unzip' 'unzip' decompression "$LOCAL_FILE" else # Normal way - install_software curl + install_software 'curl' 'curl' get_version NUMBER="$?" if [[ "$NUMBER" -eq '0' ]] || [[ "$FORCE" -eq '1' ]] || [[ "$NUMBER" -eq 2 ]]; then @@ -512,7 +519,7 @@ main() { echo "removed: $TMP_DIRECTORY" exit 0 fi - install_software unzip + install_software 'unzip' 'unzip' decompression "$ZIP_FILE" elif [[ "$NUMBER" -eq '1' ]]; then echo "info: No new version. The current version of V2Ray is $CURRENT_VERSION ." From 661312a9cc009d1aa8c5ccaf6c8724b8acbb117a Mon Sep 17 00:00:00 2001 From: IceCodeNew <32576256+IceCodeNew@users.noreply.github.com> Date: Fri, 25 Sep 2020 16:49:17 +0800 Subject: [PATCH 2/3] fix SC2120 --- install-release.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/install-release.sh b/install-release.sh index cb8ea10..59b21c5 100644 --- a/install-release.sh +++ b/install-release.sh @@ -438,7 +438,6 @@ remove_v2ray() { if [[ -n "$(pidof v2ray)" ]]; then stop_v2ray fi - NAME="$1" "rm" /usr/local/bin/v2ray "rm" /usr/local/bin/v2ctl "rm" -r "$DAT_PATH" From c40ab4a986e7c1891762cbe9cf3653125a6bdc27 Mon Sep 17 00:00:00 2001 From: IceCodeNew <32576256+IceCodeNew@users.noreply.github.com> Date: Fri, 25 Sep 2020 16:53:24 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=AE=8C=E5=96=84=20`remove=5Fv2ray`=20?= =?UTF-8?q?=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- install-release.sh | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/install-release.sh b/install-release.sh index 59b21c5..2481173 100644 --- a/install-release.sh +++ b/install-release.sh @@ -441,8 +441,10 @@ remove_v2ray() { "rm" /usr/local/bin/v2ray "rm" /usr/local/bin/v2ctl "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' + "rm" -r '/etc/systemd/system/v2ray.service.d' + "rm" -r '/etc/systemd/system/v2ray@.service.d' if [[ "$?" -ne '0' ]]; then echo 'error: Failed to remove V2Ray.' exit 1 @@ -452,11 +454,17 @@ remove_v2ray() { echo "removed: $DAT_PATH" echo 'removed: /etc/systemd/system/v2ray.service' echo 'removed: /etc/systemd/system/v2ray@.service' + echo 'removed: /etc/systemd/system/v2ray.service.d' + echo 'removed: /etc/systemd/system/v2ray@.service.d' echo 'Please execute the command: systemctl disable v2ray' echo "You may need to execute a command to remove dependent software: $PACKAGE_MANAGEMENT_REMOVE curl unzip" echo 'info: V2Ray has been removed.' echo 'info: If necessary, manually delete the configuration and log files.' - echo "info: e.g., $JSON_PATH and /var/log/v2ray/ ..." + if [[ -n "$JSONS_PATH" ]]; then + echo "info: e.g., $JSONS_PATH and /var/log/v2ray/ ..." + else + echo "info: e.g., $JSON_PATH and /var/log/v2ray/ ..." + fi exit 0 fi else