Skip to content

Commit ca6e20b

Browse files
authored
Merge pull request v2fly#22 from v2fly/develop
fix: Dealing with errors in service judgment
2 parents 86b6abc + 9e23002 commit ca6e20b

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

install-release.sh

+9-2
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,11 @@ install_startup_service_file() {
378378

379379
start_v2ray() {
380380
if [[ -f '/etc/systemd/system/v2ray.service' ]]; then
381-
systemctl start v2ray
381+
if [[ -z "$V2RAY_CUSTOMIZE" ]]; then
382+
systemctl start v2ray
383+
else
384+
systemctl start "$V2RAY_CUSTOMIZE"
385+
fi
382386
fi
383387
if [[ "$?" -ne 0 ]]; then
384388
echo 'error: Failed to start V2Ray service.'
@@ -388,8 +392,11 @@ start_v2ray() {
388392
}
389393

390394
stop_v2ray() {
391-
if [[ -f '/etc/systemd/system/v2ray.service' ]]; then
395+
V2RAY_CUSTOMIZE="$(systemctl list-units | grep 'v2ray@' | awk -F ' ' '{print $1}')"
396+
if [[ -z "$V2RAY_CUSTOMIZE" ]]; then
392397
systemctl stop v2ray
398+
else
399+
systemctl stop "$V2RAY_CUSTOMIZE"
393400
fi
394401
if [[ "$?" -ne '0' ]]; then
395402
echo 'error: Stopping the V2Ray service failed.'

0 commit comments

Comments
 (0)