Merge pull request #22 from v2fly/develop

fix: Dealing with errors in service judgment
pull/23/head
Dct Mei 2020-07-10 23:38:28 +00:00 committed by GitHub
commit ca6e20b1d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 2 deletions

View File

@ -378,7 +378,11 @@ install_startup_service_file() {
start_v2ray() {
if [[ -f '/etc/systemd/system/v2ray.service' ]]; then
systemctl start v2ray
if [[ -z "$V2RAY_CUSTOMIZE" ]]; then
systemctl start v2ray
else
systemctl start "$V2RAY_CUSTOMIZE"
fi
fi
if [[ "$?" -ne 0 ]]; then
echo 'error: Failed to start V2Ray service.'
@ -388,8 +392,11 @@ start_v2ray() {
}
stop_v2ray() {
if [[ -f '/etc/systemd/system/v2ray.service' ]]; then
V2RAY_CUSTOMIZE="$(systemctl list-units | grep 'v2ray@' | awk -F ' ' '{print $1}')"
if [[ -z "$V2RAY_CUSTOMIZE" ]]; then
systemctl stop v2ray
else
systemctl stop "$V2RAY_CUSTOMIZE"
fi
if [[ "$?" -ne '0' ]]; then
echo 'error: Stopping the V2Ray service failed.'