fix: error when removing v2ctl for v5

v2ctl has been removed since v5, so the script will fail during removing.

```
rm: cannot remove '/usr/local/bin/v2ctl': No such file or directory
error: Failed to remove V2Ray.
```
pull/246/head
Dct Mei 2022-09-15 14:31:32 +00:00 committed by GitHub
parent 941b15cb22
commit 5e547ab6b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 4 deletions

View File

@ -334,7 +334,13 @@ install_file() {
install_v2ray() { install_v2ray() {
# Install V2Ray binary to /usr/local/bin/ and $DAT_PATH # Install V2Ray binary to /usr/local/bin/ and $DAT_PATH
install_file v2ray install_file v2ray
install_file v2ctl if [[ -f "${TMP_DIRECTORY}/v2ctl" ]]; then
install_file v2ctl
else
if [[ -f '/usr/local/bin/v2ctl' ]]; then
rm '/usr/local/bin/v2ctl'
fi
fi
install -d "$DAT_PATH" install -d "$DAT_PATH"
# If the file exists, geoip.dat and geosite.dat will not be installed or updated # If the file exists, geoip.dat and geosite.dat will not be installed or updated
if [[ ! -f "${DAT_PATH}/.undat" ]]; then if [[ ! -f "${DAT_PATH}/.undat" ]]; then
@ -472,7 +478,6 @@ remove_v2ray() {
stop_v2ray stop_v2ray
fi fi
if ! ("rm" -r '/usr/local/bin/v2ray' \ if ! ("rm" -r '/usr/local/bin/v2ray' \
'/usr/local/bin/v2ctl' \
"$DAT_PATH" \ "$DAT_PATH" \
'/etc/systemd/system/v2ray.service' \ '/etc/systemd/system/v2ray.service' \
'/etc/systemd/system/v2ray@.service' \ '/etc/systemd/system/v2ray@.service' \
@ -482,7 +487,10 @@ remove_v2ray() {
exit 1 exit 1
else else
echo 'removed: /usr/local/bin/v2ray' echo 'removed: /usr/local/bin/v2ray'
echo 'removed: /usr/local/bin/v2ctl' if [[ -f '/usr/local/bin/v2ctl' ]]; then
rm '/usr/local/bin/v2ctl'
echo 'removed: /usr/local/bin/v2ctl'
fi
echo "removed: $DAT_PATH" 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' echo 'removed: /etc/systemd/system/v2ray@.service'
@ -577,7 +585,9 @@ main() {
install_v2ray install_v2ray
install_startup_service_file install_startup_service_file
echo 'installed: /usr/local/bin/v2ray' echo 'installed: /usr/local/bin/v2ray'
echo 'installed: /usr/local/bin/v2ctl' if [[ -f '/usr/local/bin/v2ctl' ]]; then
echo 'installed: /usr/local/bin/v2ctl'
fi
# If the file exists, the content output of installing or updating geoip.dat and geosite.dat will not be displayed # If the file exists, the content output of installing or updating geoip.dat and geosite.dat will not be displayed
if [[ ! -f "${DAT_PATH}/.undat" ]]; then if [[ ! -f "${DAT_PATH}/.undat" ]]; then
echo "installed: ${DAT_PATH}/geoip.dat" echo "installed: ${DAT_PATH}/geoip.dat"