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 c04cd35..6a0c652 100644 --- a/install-dat-release.sh +++ b/install-dat-release.sh @@ -17,6 +17,14 @@ 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 you want to run as another user, please modify $UID to be owned by this user + if [[ "$UID" -ne '0' ]]; then + echo "error: You must run this script as root!" + exit 1 + fi +} + download_geoip() { if ! curl -L -H 'Cache-Control: no-cache' -o "${V2RAY}geoip.dat.new" "$DOWNLOAD_LINK_GEOIP"; then echo 'error: Download failed! Please check your network or try again.' @@ -53,13 +61,14 @@ download_geosite() { rename_new() { for DAT in 'geoip' 'geosite'; do - install -m 755 "${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 } main() { + check_if_running_as_root download_geoip download_geosite rename_new diff --git a/install-release.sh b/install-release.sh index 8c75fad..496c4c5 100644 --- a/install-release.sh +++ b/install-release.sh @@ -12,6 +12,14 @@ # If the script executes incorrectly, go to: # 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" -ne '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 @@ -318,7 +326,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 -m 644 "${TMP_DIRECTORY}$NAME" "/usr/local/lib/v2ray/$NAME" fi } @@ -362,8 +370,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 -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 } @@ -453,6 +461,7 @@ show_help() { } main() { + check_if_running_as_root identify_the_operating_system_and_architecture judgment_parameters "$@"