From a0a1c5af20ba83249fce9a60a5b9ae8c18f7cbed Mon Sep 17 00:00:00 2001 From: tzwjkl Date: Sat, 6 Jun 2020 15:29:44 +0800 Subject: [PATCH 1/5] Remove unnecessary permission changes. --- install-dat-release.sh | 2 +- install-release.sh | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/install-dat-release.sh b/install-dat-release.sh index ea6292c..e85b278 100644 --- a/install-dat-release.sh +++ b/install-dat-release.sh @@ -57,7 +57,7 @@ download_geosite() { rename_new() { for DAT in 'geoip' 'geosite'; do - install -m 755 "${V2RAY}$DAT.dat.new" "${V2RAY}$DAT.dat" + install "${V2RAY}$DAT.dat.new" "${V2RAY}$DAT.dat" rm "${V2RAY}$DAT.dat.new" rm "${V2RAY}$DAT.dat.sha256sum.new" done diff --git a/install-release.sh b/install-release.sh index 6b8ba40..b415eab 100644 --- a/install-release.sh +++ b/install-release.sh @@ -322,7 +322,7 @@ install_file() { if [[ "$NAME" == 'v2ray' ]] || [[ "$NAME" == 'v2ctl' ]]; then install -m 755 "${TMP_DIRECTORY}$NAME" "/usr/local/bin/$NAME" elif [[ "$NAME" == 'geoip.dat' ]] || [[ "$NAME" == 'geosite.dat' ]]; then - install -m 755 "${TMP_DIRECTORY}$NAME" "/usr/local/lib/v2ray/$NAME" + install "${TMP_DIRECTORY}$NAME" "/usr/local/lib/v2ray/$NAME" fi } @@ -368,8 +368,8 @@ install_startup_service_file() { echo 'error: Failed to start service file download! Please check your network or try again.' exit 1 fi - install -m 755 "${TMP_DIRECTORY}systemd/system/v2ray.service" /etc/systemd/system/v2ray.service - install -m 755 "${TMP_DIRECTORY}systemd/system/v2ray@.service" /etc/systemd/system/v2ray@.service + install "${TMP_DIRECTORY}systemd/system/v2ray.service" /etc/systemd/system/v2ray.service + install "${TMP_DIRECTORY}systemd/system/v2ray@.service" /etc/systemd/system/v2ray@.service SYSTEMD='1' fi } From 4488a5c20b50e30bfc604842db4fe3a4e508e7c8 Mon Sep 17 00:00:00 2001 From: tzwjkl Date: Mon, 8 Jun 2020 03:38:51 +0800 Subject: [PATCH 2/5] Add root uid judgment before running --- install-dat-release.sh | 8 ++++++++ install-release.sh | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/install-dat-release.sh b/install-dat-release.sh index e85b278..523a692 100644 --- a/install-dat-release.sh +++ b/install-dat-release.sh @@ -17,6 +17,13 @@ V2RAY="/usr/local/lib/v2ray/" DOWNLOAD_LINK_GEOIP="https://github.com/v2ray/geoip/releases/latest/download/geoip.dat" DOWNLOAD_LINK_GEOSITE="https://github.com/v2ray/domain-list-community/releases/latest/download/dlc.dat" +check_if_running_as_root() { + if [ $UID != "0" ]; then + echo "error: You must run this script as root!" + exit 1 + fi +} + download_geoip() { curl -L -H 'Cache-Control: no-cache' -o "${V2RAY}geoip.dat.new" "$DOWNLOAD_LINK_GEOIP" if [ "$?" -ne '0' ]; then @@ -64,6 +71,7 @@ rename_new() { } main() { + check_if_running_as_root download_geoip download_geosite rename_new diff --git a/install-release.sh b/install-release.sh index b415eab..5a459f8 100644 --- a/install-release.sh +++ b/install-release.sh @@ -12,6 +12,13 @@ # If the script executes incorrectly, go to: # https://github.com/v2fly/fhs-install-v2ray/issues +check_if_running_as_root() { + if [ $UID != "0" ]; then + echo "error: You must run this script as root!" + exit 1 + fi +} + identify_the_operating_system_and_architecture() { if [[ "$(uname)" == 'Linux' ]]; then case "$(uname -m)" in @@ -459,6 +466,7 @@ show_help() { } main() { + check_if_running_as_root identify_the_operating_system_and_architecture judgment_parameters "$@" From 9bfbc5df76d56bc2b6aae440a32939e51beb394b Mon Sep 17 00:00:00 2001 From: tzwjkl Date: Mon, 8 Jun 2020 04:20:43 +0800 Subject: [PATCH 3/5] Add Comments for check_if_running_as_root() --- install-dat-release.sh | 1 + install-release.sh | 1 + 2 files changed, 2 insertions(+) diff --git a/install-dat-release.sh b/install-dat-release.sh index 523a692..292b6a2 100644 --- a/install-dat-release.sh +++ b/install-dat-release.sh @@ -18,6 +18,7 @@ DOWNLOAD_LINK_GEOIP="https://github.com/v2ray/geoip/releases/latest/download/geo DOWNLOAD_LINK_GEOSITE="https://github.com/v2ray/domain-list-community/releases/latest/download/dlc.dat" check_if_running_as_root() { + # If you want to run as another user, please modify $UID to be owned by this user if [ $UID != "0" ]; then echo "error: You must run this script as root!" exit 1 diff --git a/install-release.sh b/install-release.sh index 5a459f8..d4efa4d 100644 --- a/install-release.sh +++ b/install-release.sh @@ -13,6 +13,7 @@ # https://github.com/v2fly/fhs-install-v2ray/issues check_if_running_as_root() { + # If you want to run as another user, please modify $UID to be owned by this user if [ $UID != "0" ]; then echo "error: You must run this script as root!" exit 1 From b92ed1985b0386aaeba6bb3e74377b47a630fc46 Mon Sep 17 00:00:00 2001 From: tzwjkl Date: Thu, 11 Jun 2020 15:35:50 +0800 Subject: [PATCH 4/5] fix install mode parameter --- install-dat-release.sh | 2 +- install-release.sh | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/install-dat-release.sh b/install-dat-release.sh index 292b6a2..28e389e 100644 --- a/install-dat-release.sh +++ b/install-dat-release.sh @@ -65,7 +65,7 @@ download_geosite() { rename_new() { for DAT in 'geoip' 'geosite'; do - install "${V2RAY}$DAT.dat.new" "${V2RAY}$DAT.dat" + install -m 644 "${V2RAY}$DAT.dat.new" "${V2RAY}$DAT.dat" rm "${V2RAY}$DAT.dat.new" rm "${V2RAY}$DAT.dat.sha256sum.new" done diff --git a/install-release.sh b/install-release.sh index 1ec8818..5fd5dbf 100644 --- a/install-release.sh +++ b/install-release.sh @@ -330,7 +330,7 @@ install_file() { if [[ "$NAME" == 'v2ray' ]] || [[ "$NAME" == 'v2ctl' ]]; then install -m 755 "${TMP_DIRECTORY}$NAME" "/usr/local/bin/$NAME" elif [[ "$NAME" == 'geoip.dat' ]] || [[ "$NAME" == 'geosite.dat' ]]; then - install "${TMP_DIRECTORY}$NAME" "/usr/local/lib/v2ray/$NAME" + install -m 644 "${TMP_DIRECTORY}$NAME" "/usr/local/lib/v2ray/$NAME" fi } @@ -376,8 +376,8 @@ install_startup_service_file() { echo 'error: Failed to start service file download! Please check your network or try again.' exit 1 fi - install "${TMP_DIRECTORY}systemd/system/v2ray.service" /etc/systemd/system/v2ray.service - install "${TMP_DIRECTORY}systemd/system/v2ray@.service" /etc/systemd/system/v2ray@.service + install -m 644 "${TMP_DIRECTORY}systemd/system/v2ray.service" /etc/systemd/system/v2ray.service + install -m 644 "${TMP_DIRECTORY}systemd/system/v2ray@.service" /etc/systemd/system/v2ray@.service SYSTEMD='1' fi } From 38da8a7b93ad74b3f113605ed769f14d90f2a43c Mon Sep 17 00:00:00 2001 From: Dct Mei Date: Sat, 13 Jun 2020 20:44:22 +0800 Subject: [PATCH 5/5] style: Canonical code format 1. Regulate two judgments, this will not cause functional changes. 2. Add some supplementary content, mainly for subsequent maintenance. --- README.md | 10 ++++++++++ install-dat-release.sh | 2 +- install-release.sh | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 87b50d9..bc2ec71 100644 --- a/README.md +++ b/README.md @@ -31,24 +31,28 @@ installed: /etc/systemd/system/v2ray@.service ### 安裝 cURL ``` +# apt update # apt install curl ``` or ``` +# yum makecache # yum install curl ``` or ``` +# dnf makecache # dnf install curl ``` or ``` +# zypper refresh # zypper install curl ``` @@ -94,3 +98,9 @@ usage: install-release.sh [--remove | --version number | -c | -f | -h | -l | -p] -l, --local Install V2Ray from a local file -p, --proxy Download through a proxy server, e.g., -p http://127.0.0.1:8118 or -p socks5://127.0.0.1:1080 ``` + +## 維護 + +請於 [develop](https://github.com/v2fly/fhs-install-v2ray/tree/develop) 分支進行,以避免對主分支造成破壞。 + +待確定無誤後,兩分支將進行合併。 diff --git a/install-dat-release.sh b/install-dat-release.sh index b866168..6a0c652 100644 --- a/install-dat-release.sh +++ b/install-dat-release.sh @@ -19,7 +19,7 @@ DOWNLOAD_LINK_GEOSITE="https://github.com/v2ray/domain-list-community/releases/l check_if_running_as_root() { # If you want to run as another user, please modify $UID to be owned by this user - if [ $UID != "0" ]; then + if [[ "$UID" -ne '0' ]]; then echo "error: You must run this script as root!" exit 1 fi diff --git a/install-release.sh b/install-release.sh index 341114f..496c4c5 100644 --- a/install-release.sh +++ b/install-release.sh @@ -14,7 +14,7 @@ check_if_running_as_root() { # If you want to run as another user, please modify $UID to be owned by this user - if [ $UID != "0" ]; then + if [[ "$UID" -ne '0' ]]; then echo "error: You must run this script as root!" exit 1 fi