@@ -415,11 +415,11 @@ start_v2ray() {
415
415
stop_v2ray () {
416
416
V2RAY_CUSTOMIZE=" $( systemctl list-units | grep ' v2ray@' | awk -F ' ' ' {print $1}' ) "
417
417
if [[ -z " $V2RAY_CUSTOMIZE " ]]; then
418
- systemctl stop v2ray
418
+ local v2ray_daemon_to_stop= ' v2ray.service '
419
419
else
420
- systemctl stop " $V2RAY_CUSTOMIZE "
420
+ local v2ray_daemon_to_stop= " $V2RAY_CUSTOMIZE "
421
421
fi
422
- if [[ " $? " -ne ' 0 ' ]] ; then
422
+ if ! systemctl stop " $v2ray_daemon_to_stop " ; then
423
423
echo ' error: Stopping the V2Ray service failed.'
424
424
exit 1
425
425
fi
@@ -428,10 +428,11 @@ stop_v2ray() {
428
428
429
429
check_update () {
430
430
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
433
434
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
435
436
echo " info: No new version. The current version of V2Ray is $CURRENT_VERSION ."
436
437
fi
437
438
exit 0
@@ -446,14 +447,13 @@ remove_v2ray() {
446
447
if [[ -n " $( pidof v2ray) " ]]; then
447
448
stop_v2ray
448
449
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
457
457
echo ' error: Failed to remove V2Ray.'
458
458
exit 1
459
459
else
0 commit comments