From 617ab1bd07c5d32996acc3395c282df332703a55 Mon Sep 17 00:00:00 2001 From: IceCodeNew <32576256+IceCodeNew@users.noreply.github.com> Date: Wed, 30 Sep 2020 18:07:56 +0800 Subject: [PATCH 1/5] Always use latest script rather than a local cached script. --- README.md | 8 +++----- README.zh-Hans-CN.md | 8 +++----- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index f18e318..e89a51f 100644 --- a/README.md +++ b/README.md @@ -33,22 +33,20 @@ installed: /etc/systemd/system/v2ray@.service ``` // 安裝執行檔和 .dat 資料檔 -# curl -LROJ https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh -# bash install-release.sh +# bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh) ``` ### 安裝最新發行的 geoip.dat 和 geosite.dat ``` // 只更新 .dat 資料檔 -# curl -LROJ https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-dat-release.sh -# bash install-dat-release.sh +# bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-dat-release.sh) ``` ### 移除 V2Ray ``` -# bash install-release.sh --remove +# bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh) --remove ``` ### 解決問題 diff --git a/README.zh-Hans-CN.md b/README.zh-Hans-CN.md index 411bf53..71fe73d 100644 --- a/README.zh-Hans-CN.md +++ b/README.zh-Hans-CN.md @@ -33,22 +33,20 @@ installed: /etc/systemd/system/v2ray@.service ``` // 安装可执行文件和 .dat 数据文件 -# curl -LROJ https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh -# bash install-release.sh +# bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh) ``` ### 安装最新发行的 geoip.dat 和 geosite.dat ``` // 只更新 .dat 数据文件 -# curl -LROJ https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-dat-release.sh -# bash install-dat-release.sh +# bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-dat-release.sh) ``` ### 移除 V2Ray ``` -# bash install-release.sh --remove +# bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh) --remove ``` ### 解决问题 From 2894fc4e9ac430422f0252edfab1f5cf645ac3e5 Mon Sep 17 00:00:00 2001 From: IceCodeNew <32576256+IceCodeNew@users.noreply.github.com> Date: Wed, 30 Sep 2020 18:23:22 +0800 Subject: [PATCH 2/5] rm configuration file which could mess things up. --- install-release.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/install-release.sh b/install-release.sh index 46e6ec0..f911ee6 100644 --- a/install-release.sh +++ b/install-release.sh @@ -362,6 +362,8 @@ install_startup_service_file() { mkdir -p '/etc/systemd/system/v2ray.service.d' mkdir -p '/etc/systemd/system/v2ray@.service.d/' if [[ -n "$JSONS_PATH" ]]; then + "rm" '/etc/systemd/system/v2ray.service.d/10-donot_touch_single_conf.conf' \ + '/etc/systemd/system/v2ray@.service.d/10-donot_touch_single_conf.conf'; echo "# 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] @@ -370,6 +372,8 @@ ExecStart=/usr/local/bin/v2ray -confdir $JSONS_PATH" | tee '/etc/systemd/system/v2ray.service.d/10-donot_touch_multi_conf.conf' > \ '/etc/systemd/system/v2ray@.service.d/10-donot_touch_multi_conf.conf' else + "rm" '/etc/systemd/system/v2ray.service.d/10-donot_touch_multi_conf.conf' \ + '/etc/systemd/system/v2ray@.service.d/10-donot_touch_multi_conf.conf'; echo "${red}~~~~~~~~~~~~~~~~ ${green}/etc/systemd/system/v2ray.service.d/10-donot_touch_single_conf ${red}~~~~~~~~~~~~~~~~${reset}" echo 'info: The following are the actual parameters for the v2ray service startup.' echo 'info: Please make sure the configuration file path is correctly set.' From 69aaf1981f620ad7a50f5fca6c45151011186a85 Mon Sep 17 00:00:00 2001 From: IceCodeNew <32576256+IceCodeNew@users.noreply.github.com> Date: Wed, 30 Sep 2020 19:06:02 +0800 Subject: [PATCH 3/5] Chore Signed-off-by: IceCodeNew <32576256+IceCodeNew@users.noreply.github.com> --- install-release.sh | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/install-release.sh b/install-release.sh index f911ee6..7049e59 100644 --- a/install-release.sh +++ b/install-release.sh @@ -23,6 +23,9 @@ JSON_PATH=${JSON_PATH:-/usr/local/etc/v2ray} # Set this variable only if you are starting v2ray with multiple configuration files: # export JSONS_PATH='/usr/local/etc/v2ray' +# Set this variable only if you want this script to check all the systemd unit file: +# export check_all_service_files='yes' + curl() { $(type -P curl) -L -q --retry 5 --retry-delay 10 --retry-max-time 60 "$@" } @@ -364,8 +367,8 @@ install_startup_service_file() { if [[ -n "$JSONS_PATH" ]]; then "rm" '/etc/systemd/system/v2ray.service.d/10-donot_touch_single_conf.conf' \ '/etc/systemd/system/v2ray@.service.d/10-donot_touch_single_conf.conf'; - echo "# 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 + 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 -confdir $JSONS_PATH" | @@ -374,29 +377,27 @@ ExecStart=/usr/local/bin/v2ray -confdir $JSONS_PATH" | else "rm" '/etc/systemd/system/v2ray.service.d/10-donot_touch_multi_conf.conf' \ '/etc/systemd/system/v2ray@.service.d/10-donot_touch_multi_conf.conf'; - echo "${red}~~~~~~~~~~~~~~~~ ${green}/etc/systemd/system/v2ray.service.d/10-donot_touch_single_conf ${red}~~~~~~~~~~~~~~~~${reset}" - echo 'info: The following are the actual parameters for the v2ray service startup.' - echo 'info: Please make sure the configuration file path is correctly set.' - echo "# 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 + 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}/config.json" | - tee '/etc/systemd/system/v2ray.service.d/10-donot_touch_single_conf.conf' - echo - echo - - echo "${red}~~~~~~~~~~~~~~~~ ${green}/etc/systemd/system/v2ray@.service.d/10-donot_touch_single_conf ${red}~~~~~~~~~~~~~~~~${reset}" - echo 'info: The following are the actual parameters for the v2ray service startup.' - echo 'info: Please make sure the configuration file path is correctly set.' - echo "# 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 +ExecStart=/usr/local/bin/v2ray -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" | - tee '/etc/systemd/system/v2ray@.service.d/10-donot_touch_single_conf.conf' +ExecStart=/usr/local/bin/v2ray -config ${JSON_PATH}/%i.json" > \ + '/etc/systemd/system/v2ray@.service.d/10-donot_touch_single_conf.conf' + fi + echo "info: Systemd service files have been installed successfully!" + echo "${red}warning: ${green}The following are the actual parameters for the v2ray service startup." + echo "${red}warning: ${green}Please make sure the configuration file path is correctly set.${reset}" + systemd-analyze cat-config /etc/systemd/system/v2ray.service + if [[ x"${check_all_service_files:0:1}" = x'y' ]]; then echo echo + systemd-analyze cat-config /etc/systemd/system/v2ray@.service fi systemctl daemon-reload SYSTEMD='1' From 5b9271337024b753a74703b2ea1f22f590f5588a Mon Sep 17 00:00:00 2001 From: IceCodeNew <32576256+IceCodeNew@users.noreply.github.com> Date: Wed, 30 Sep 2020 19:07:47 +0800 Subject: [PATCH 4/5] Fix SC2162; shfmt -i 2 -ci -sr Signed-off-by: IceCodeNew <32576256+IceCodeNew@users.noreply.github.com> --- install-release.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/install-release.sh b/install-release.sh index 7049e59..8e9d5b2 100644 --- a/install-release.sh +++ b/install-release.sh @@ -366,7 +366,7 @@ install_startup_service_file() { mkdir -p '/etc/systemd/system/v2ray@.service.d/' if [[ -n "$JSONS_PATH" ]]; then "rm" '/etc/systemd/system/v2ray.service.d/10-donot_touch_single_conf.conf' \ - '/etc/systemd/system/v2ray@.service.d/10-donot_touch_single_conf.conf'; + '/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] @@ -376,7 +376,7 @@ ExecStart=/usr/local/bin/v2ray -confdir $JSONS_PATH" | '/etc/systemd/system/v2ray@.service.d/10-donot_touch_multi_conf.conf' else "rm" '/etc/systemd/system/v2ray.service.d/10-donot_touch_multi_conf.conf' \ - '/etc/systemd/system/v2ray@.service.d/10-donot_touch_multi_conf.conf'; + '/etc/systemd/system/v2ray@.service.d/10-donot_touch_multi_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] @@ -520,7 +520,7 @@ main() { if [[ "$LOCAL_INSTALL" -eq '1' ]]; then echo 'warn: Install V2Ray from a local file, but still need to make sure the network is available.' echo -n 'warn: Please make sure the file is valid because we cannot confirm it. (Press any key) ...' - read + read -r install_software "$package_provide_bsdtar" 'bsdtar' decompression "$LOCAL_FILE" else From 38017e9d901eaf34fa33d245ddb950cae14d9b43 Mon Sep 17 00:00:00 2001 From: IceCodeNew <32576256+IceCodeNew@users.noreply.github.com> Date: Wed, 30 Sep 2020 19:18:43 +0800 Subject: [PATCH 5/5] Suggest `no-cache` header. --- README.md | 8 ++++---- README.zh-Hans-CN.md | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index e89a51f..dab50d6 100644 --- a/README.md +++ b/README.md @@ -27,26 +27,26 @@ installed: /etc/systemd/system/v2ray@.service ## 使用 -* 該腳本在執行時會提供 `info` 和 `error` 等信息,請仔細閱讀。 +* 該腳本在執行時會提供 `info`、`warning` 和 `error` 等信息,請仔細閱讀。 ### 安裝和更新 V2Ray ``` // 安裝執行檔和 .dat 資料檔 -# bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh) +# bash <(curl -H 'Cache-Control: no-cache' -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh) ``` ### 安裝最新發行的 geoip.dat 和 geosite.dat ``` // 只更新 .dat 資料檔 -# bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-dat-release.sh) +# bash <(curl -H 'Cache-Control: no-cache' -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-dat-release.sh) ``` ### 移除 V2Ray ``` -# bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh) --remove +# bash <(curl -H 'Cache-Control: no-cache' -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh) --remove ``` ### 解決問題 diff --git a/README.zh-Hans-CN.md b/README.zh-Hans-CN.md index 71fe73d..c12d4f4 100644 --- a/README.zh-Hans-CN.md +++ b/README.zh-Hans-CN.md @@ -27,26 +27,26 @@ installed: /etc/systemd/system/v2ray@.service ## 使用 -* 该脚本在运行时会提供 `info` 和 `error` 等信息,请仔细阅读。 +* 该脚本在运行时会提供 `info`、`warning` 和 `error` 等信息,请仔细阅读。 ### 安装和更新 V2Ray ``` // 安装可执行文件和 .dat 数据文件 -# bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh) +# bash <(curl -H 'Cache-Control: no-cache' -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh) ``` ### 安装最新发行的 geoip.dat 和 geosite.dat ``` // 只更新 .dat 数据文件 -# bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-dat-release.sh) +# bash <(curl -H 'Cache-Control: no-cache' -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-dat-release.sh) ``` ### 移除 V2Ray ``` -# bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh) --remove +# bash <(curl -H 'Cache-Control: no-cache' -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh) --remove ``` ### 解决问题