Skip to content

Commit 50593bb

Browse files
committed
fix SC2181
1 parent 656fa81 commit 50593bb

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

install-release.sh

+14-14
Original file line numberDiff line numberDiff line change
@@ -415,11 +415,11 @@ start_v2ray() {
415415
stop_v2ray() {
416416
V2RAY_CUSTOMIZE="$(systemctl list-units | grep 'v2ray@' | awk -F ' ' '{print $1}')"
417417
if [[ -z "$V2RAY_CUSTOMIZE" ]]; then
418-
systemctl stop v2ray
418+
local v2ray_daemon_to_stop='v2ray.service'
419419
else
420-
systemctl stop "$V2RAY_CUSTOMIZE"
420+
local v2ray_daemon_to_stop="$V2RAY_CUSTOMIZE"
421421
fi
422-
if [[ "$?" -ne '0' ]]; then
422+
if ! systemctl stop "$v2ray_daemon_to_stop"; then
423423
echo 'error: Stopping the V2Ray service failed.'
424424
exit 1
425425
fi
@@ -428,10 +428,11 @@ stop_v2ray() {
428428

429429
check_update() {
430430
if [[ -f '/etc/systemd/system/v2ray.service' ]]; then
431-
get_version
432-
if [[ "$?" -eq '0' ]]; then
431+
(get_version)
432+
local get_ver_exit_code=$?
433+
if [[ "$get_ver_exit_code" -eq '0' ]]; then
433434
echo "info: Found the latest release of V2Ray $RELEASE_VERSION . (Current release: $CURRENT_VERSION)"
434-
elif [[ "$?" -eq '1' ]]; then
435+
elif [[ "$get_ver_exit_code" -eq '1' ]]; then
435436
echo "info: No new version. The current version of V2Ray is $CURRENT_VERSION ."
436437
fi
437438
exit 0
@@ -446,14 +447,13 @@ remove_v2ray() {
446447
if [[ -n "$(pidof v2ray)" ]]; then
447448
stop_v2ray
448449
fi
449-
"rm" /usr/local/bin/v2ray
450-
"rm" /usr/local/bin/v2ctl
451-
"rm" -r "$DAT_PATH"
452-
"rm" '/etc/systemd/system/v2ray.service'
453-
"rm" '/etc/systemd/system/v2ray@.service'
454-
"rm" -r '/etc/systemd/system/v2ray.service.d'
455-
"rm" -r '/etc/systemd/system/v2ray@.service.d'
456-
if [[ "$?" -ne '0' ]]; then
450+
if ! ("rm" -r '/usr/local/bin/v2ray' \
451+
'/usr/local/bin/v2ctl' \
452+
"$DAT_PATH" \
453+
'/etc/systemd/system/v2ray.service' \
454+
'/etc/systemd/system/v2ray@.service' \
455+
'/etc/systemd/system/v2ray.service.d' \
456+
'/etc/systemd/system/v2ray@.service.d'); then
457457
echo 'error: Failed to remove V2Ray.'
458458
exit 1
459459
else

0 commit comments

Comments
 (0)