forked from v2fly/fhs-install-v2ray
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: incompatible CLI usage since v5
fixes: v2fly#243
- Loading branch information
Showing
1 changed file
with
19 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -216,6 +216,15 @@ install_software() { | |
fi | ||
} | ||
|
||
get_current_version() { | ||
if /usr/local/bin/v2ray -version >/dev/null 2>&1;then | ||
VERSION="$(/usr/local/bin/v2ray -version | awk 'NR==1 {print $2}')" | ||
else | ||
VERSION="$(/usr/local/bin/v2ray version | awk 'NR==1 {print $2}')" | ||
fi | ||
CURRENT_VERSION="v${VERSION#v}" | ||
} | ||
|
||
get_version() { | ||
# 0: Install or update V2Ray. | ||
# 1: Installed or no new version of V2Ray. | ||
|
@@ -226,8 +235,7 @@ get_version() { | |
fi | ||
# Determine the version number for V2Ray installed from a local file | ||
if [[ -f '/usr/local/bin/v2ray' ]]; then | ||
VERSION="$(/usr/local/bin/v2ray -version | awk 'NR==1 {print $2}')" | ||
CURRENT_VERSION="v${VERSION#v}" | ||
get_current_version | ||
if [[ "$LOCAL_INSTALL" -eq '1' ]]; then | ||
RELEASE_VERSION="$CURRENT_VERSION" | ||
return | ||
|
@@ -367,6 +375,12 @@ install_v2ray() { | |
} | ||
|
||
install_startup_service_file() { | ||
get_current_version | ||
if [[ "${CURRENT_VERSIONSION_NUMBER%%.*}" -gt "4" ]];then | ||
START_COMMAND="/usr/local/bin/v2ray run" | ||
else | ||
START_COMMAND="/usr/local/bin/v2ray" | ||
fi | ||
install -m 644 "${TMP_DIRECTORY}/systemd/system/v2ray.service" /etc/systemd/system/v2ray.service | ||
install -m 644 "${TMP_DIRECTORY}/systemd/system/[email protected]" /etc/systemd/system/[email protected] | ||
mkdir -p '/etc/systemd/system/v2ray.service.d' | ||
|
@@ -378,7 +392,7 @@ install_startup_service_file() { | |
# Or all changes you made will be lost! # Refer: https://www.freedesktop.org/software/systemd/man/systemd.unit.html | ||
[Service] | ||
ExecStart= | ||
ExecStart=/usr/local/bin/v2ray -confdir $JSONS_PATH" | | ||
ExecStart=${START_COMMAND} -confdir $JSONS_PATH" | | ||
tee '/etc/systemd/system/v2ray.service.d/10-donot_touch_multi_conf.conf' > \ | ||
'/etc/systemd/system/[email protected]/10-donot_touch_multi_conf.conf' | ||
else | ||
|
@@ -388,13 +402,13 @@ ExecStart=/usr/local/bin/v2ray -confdir $JSONS_PATH" | | |
# Or all changes you made will be lost! # Refer: https://www.freedesktop.org/software/systemd/man/systemd.unit.html | ||
[Service] | ||
ExecStart= | ||
ExecStart=/usr/local/bin/v2ray -config ${JSON_PATH}/config.json" > \ | ||
ExecStart=${START_COMMAND} -config ${JSON_PATH}/config.json" > \ | ||
'/etc/systemd/system/v2ray.service.d/10-donot_touch_single_conf.conf' | ||
echo "# In case you have a good reason to do so, duplicate this file in the same directory and make your customizes there. | ||
# Or all changes you made will be lost! # Refer: https://www.freedesktop.org/software/systemd/man/systemd.unit.html | ||
[Service] | ||
ExecStart= | ||
ExecStart=/usr/local/bin/v2ray -config ${JSON_PATH}/%i.json" > \ | ||
ExecStart=${START_COMMAND} -config ${JSON_PATH}/%i.json" > \ | ||
'/etc/systemd/system/[email protected]/10-donot_touch_single_conf.conf' | ||
fi | ||
echo "info: Systemd service files have been installed successfully!" | ||
|