Coder Social home page Coder Social logo

v2fly / fhs-install-v2ray Goto Github PK

View Code? Open in Web Editor NEW
5.9K 5.9K 1.4K 236 KB

Bash script for installing V2Ray in operating systems such as Debian / CentOS / Fedora / openSUSE that support systemd

License: GNU General Public License v3.0

Shell 100.00%
installer script v2ray

fhs-install-v2ray's Introduction

fhs-install-v2ray

欲查阅以简体中文撰写的介绍,请访问:README.zh-Hans-CN.md

Bash script for installing V2Ray in operating systems such as Debian / CentOS / Fedora / openSUSE that support systemd

該腳本安裝的文件符合 Filesystem Hierarchy Standard (FHS)

installed: /usr/local/bin/v2ray
installed: /usr/local/bin/v2ctl
installed: /usr/local/share/v2ray/geoip.dat
installed: /usr/local/share/v2ray/geosite.dat
installed: /usr/local/etc/v2ray/config.json
installed: /var/log/v2ray/
installed: /var/log/v2ray/access.log
installed: /var/log/v2ray/error.log
installed: /etc/systemd/system/v2ray.service
installed: /etc/systemd/system/[email protected]

重要提示

不推薦在 docker 中使用本專案安裝 v2ray,請直接使用 官方映象
如果官方映象不能滿足您自定義安裝的需要,請以復刻並修改上游 dockerfile 的方式來實現

本專案不會為您自動生成配置檔案只解決使用者安裝階段遇到的問題。其他問題在這裡是無法得到幫助的。
請在安裝完成後參閱 文件 瞭解配置檔案語法,並自己完成適合自己的配置檔案。過程中可參閱社群貢獻的 配置檔案模板
提請您注意這些模板複製下來以後是需要您自己修改調整的,不能直接使用

使用

  • 該腳本在執行時會提供 infoerror 等信息,請仔細閱讀。

安裝和更新 V2Ray

// 安裝執行檔和 .dat 資料檔
# bash <(curl -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)

移除 V2Ray

# bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh) --remove

解決問題

若您的問題沒有在上方列出,歡迎在 Issue 區提出。

提問前請先閱讀 Issue #63,否則可能無法得到解答並被鎖定。

貢獻

請於 develop 分支進行,以避免對主分支造成破壞。

待確定無誤後,兩分支將進行合併。

fhs-install-v2ray's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fhs-install-v2ray's Issues

remove 時出現 error: V2Ray is not installed.

試過以下四種合法指令

bash <(curl -sL https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh) --remove
bash -c "$(curl -sL https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh)" -s --remove
curl -sL https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh | bash -s -- --remove
wget -q https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh -o /tmp/install-release.sh && chmod +x /tmp/install-release.sh && /tmp/install-release.sh --remove

都是同一個結果 error: V2Ray is not installed.

v4.27.0 无法搭配最新的install-dat-release.sh

运行v2ray 提示找不到geoip.dat, geosite.dat
麻烦尽快修复.需要发布新版本的v2ray-core?? 还是已经有了新版本,脚本检测的版本号错了?
大致问题原因:v4.27.0 二进制文件里面引用的geo 路径为旧的路径不是最新的
/usr/local/share/v2ray
我现在用的install-dat-release.sh安装v2ray跑不起来,程序报错,应该需要搭配更新版本的v2ray版本

对于包括但不限于 v2ray 的证书读取问题的一点想法

目前的 方案 的确是解决了证书的问题,不过看到隔壁 trojan-go p4gefau1t/trojan-go#171 也有这种问题之后我有了一个想法

我对目前这个项目的解决方案的看法:
nobody 用作无特权的进程确实可行,但是读取证书的话有点不合适,因为有不少无特权进程都是 nobody 运行的

我在前一段时间看到了大概是 sdk24 以上的 Android 有一个组,叫 readproc
顾名思义,在这个组的进程可以读 /proc

那么有没有一种读取证书特权组呢?
当然,在今天没有

没有?要不做一个?
于是我就有了一个想法

做一个名为 readcert.conf 的文件并且应用它
g readcert 89 "read cert"
或者执行 groupadd --system --gid 89 创建这个组

然后更改想要读取证书的 service 文件
[Service] 下加 Group=readcert

记得设置好证书的权限
chown root:readcert <证书公钥> <证书私钥> && chmod 640 <证书私钥>

[Todo] 从 Release 中获得 Systemd 文件,而不从网络下载

install_startup_service_file() {
if [[ ! -f '/etc/systemd/system/v2ray.service' ]]; then
mkdir "${TMP_DIRECTORY}systemd/system/"
install_software curl
if ! curl ${PROXY} -s -o "${TMP_DIRECTORY}systemd/system/v2ray.service" 'https://raw.githubusercontent.workers.dev/v2fly/fhs-install-v2ray/master/systemd/system/v2ray.service'; then
echo 'error: Failed to start service file download! Please check your network or try again.'
exit 1
fi
if ! curl ${PROXY} -s -o "${TMP_DIRECTORY}systemd/system/[email protected]" 'https://raw.githubusercontent.workers.dev/v2fly/fhs-install-v2ray/master/systemd/system/[email protected]'; then
echo 'error: Failed to start service file download! Please check your network or try again.'
exit 1
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]
SYSTEMD='1'
fi
}

[fix] 錯誤的安裝路徑

geoip.dat 和 geosite.dat 原被放置在 /usr/local/lib/v2ray/ 當中。

這實際上不符合 FHS,現已被修正為 /usr/local/share/v2ray/

08-16 前受此錯誤影響的用者,請按照以下示例進行修正:

# mv /usr/local/lib/v2ray/ /usr/local/share/
# systemctl edit --full v2ray.service

Environment=V2RAY_LOCATION_ASSET=/usr/local/share/v2ray/
# systemctl edit --full [email protected]

Environment=V2RAY_LOCATION_ASSET=/usr/local/share/v2ray/

v2ray 默认打开的是 /usr/local/bin/geosite.dat,一键安装包执行完后没有这个文件

启动报错

main: failed to read config files: [/usr/local/etc/v2ray/config.json] > v2ray.com/core/main/json: failed to execute v2ctl to convert config file. > v2ray.com/core/common/platform/ctlcmd: failed to execute v2ctl:
v2ctl> Read config:  /usr/local/etc/v2ray/config.json
v2ray.com/core/infra/conf: invalid field rule > v2ray.com/core/infra/conf: failed to parse domain rule: geosite:netflix > v2ray.com/core/infra/conf: failed to load geosite: NETFLIX > v2ray.com/core/infra/conf: failed to open file: geosite.dat > open /usr/local/bin/geosite.dat: no such file or directory > exit status 255

配置文件内容

/usr/local/etc/v2ray/config.json

{
  "log": {
    "access": "/var/log/v2ray/access.log",
    "error": "/var/log/v2ray/error.log",
    "loglevel": "warning"
  },
  "dns": {
    "servers": [
      "8.8.8.8",
      "8.8.4.4"
    ]
  },
  "stats": {},
  "api": {
    "tag": "api",
    "services": [
      "HandlerService",
      "StatsService"
    ]
  },
  "inbounds": [
    {
      "port": 443,
      "protocol": "vmess",
      "settings": {
        "clients": [
          {
            "id": "隐藏",
            "alterId": 1
          }
        ]
      },
      "sniffing": {
        "enabled": true,
        "destOverride": [
          "http",
          "tls"
        ]
      },
      "tag": "in-0",
      "streamSettings": {
        "network": "tcp",
        "security": "tls",
        "tcpSettings": {},
        "tlsSettings": {
          "certificates": [
            {
              "certificateFile": "/usr/local/etc/v2ray/public.pem",
              "keyFile": "/usr/local/etc/v2ray/private.key"
            }
          ]
        }
      }
    },
    {
      "listen": "127.0.0.1",
      "port": 8899,
      "protocol": "dokodemo-door",
      "settings": {
        "address": "127.0.0.1"
      },
      "tag": "api"
    }
  ],
  "outbounds": [
    {
      "tag": "direct",
      "protocol": "freedom",
      "settings": {}
    },
    {
      "tag": "netflix_vps",
      "protocol": "vmess",
      "settings": {
        "vnext": [
          {
            "address": "隐藏",
            "port": 48421,
            "users": [
              {
                "id": "隐藏",
                "security": "auto",
                "alterId": 1
              }
            ]
          }
        ]
      },
      "streamSettings": {
        "network": "tcp"
      }
    },
    {
      "tag": "blocked",
      "protocol": "blackhole",
      "settings": {}
    }
  ],
  "routing": {
    "settings": {
      "rules": [
        {
          "inboundTag": [
            "api"
          ],
          "outboundTag": "api",
          "type": "field"
        },
        {
          "type": "field",
          "outboundTag": "netflix_vps",
          "domain": [
            "geosite:netflix",
            "geosite:google-scholar",
            "geosite:wikileaks",
            "ip.sb"
          ]
        }
      ]
    },
    "strategy": "rules"
  },
  "policy": {
    "levels": {
      "0": {
        "statsUserUplink": true,
        "statsUserDownlink": true,
        "handshake": 18,
        "connIdle": 300,
        "uplinkOnly": 18,
        "downlinkOnly": 16,
        "bufferSize": 128
      }
    },
    "system": {
      "statsInboundUplink": true,
      "statsInboundDownlink": true
    }
  },
  "reverse": {},
  "transport": {}
}

尝试读取let's encrypt证书时权限不足

Jun 3 11:33:40 主机名 systemd[1]: Started V2Ray Service.
Jun 3 11:33:40 主机名 v2ray[28708]: V2Ray 4.23.3 (V2Fly, a community-driven edition of V2Ray.) Custom (go1.14.1 linux/amd64)
Jun 3 11:33:40 主机名 v2ray[28708]: A unified platform for anti-censorship.
Jun 3 11:33:41 主机名 v2ray[28708]: main: failed to read config files: [/usr/local/etc/v2ray/config.json] > v2ray.com/core/main/json: failed to execute v2ctl to convert config file. > v2ray.com/core/common/platform/ctlcmd: failed to execute v2ctl:
Jun 3 11:33:41 主机名 v2ray[28708]: v2ctl> Read config: /usr/local/etc/v2ray/config.json
Jun 3 11:33:41 主机名 v2ray[28708]: v2ray.com/core/infra/conf: Failed to build TLS config. > v2ray.com/core/infra/conf: failed to parse certificate > open /etc/letsencrypt/live/域名/fullchain.pem: permission denied > exit status 255
Jun 3 11:33:41 主机名 systemd[1]: [email protected]: Main process exited, code=exited, status=23/n/a
Jun 3 11:33:41 主机名 systemd[1]: [email protected]: Failed with result 'exit-code'.
Jun 3 11:33:41 主机名 systemd[1]: [email protected]: Service RestartSec=100ms expired, scheduling restart.
Jun 3 11:33:41 主机名 systemd[1]: [email protected]: Scheduled restart job, restart counter is at 5.
Jun 3 11:33:41 主机名 systemd[1]: Stopped V2Ray Service.

目前暂时这样解决:

[Service]
User=root

不知道有没有更好的办法。

运行脚本时可选择不更新 geosite.dat 和 geoip.dat

如题,希望可以添加个参数能让 geosite.datgeoip.dat 不跟随 V2Ray 更新。

原因

自定义了 geosite.datgeoip.dat 并且名字也是用的 geositegeoip,使用脚本更新时会被一同覆盖。
虽然可以改名字并在配置文件中使用 ext 解决,但是这样还是会多出来两个文件并且还用不到

The change seems breaking the compatibility with multi-config-files in default situation

Hello developers,

I used the install-script to install V2Ray on a Debian 10 machine since July and used the default v2ray.service to start it as a service, and everything worked fine. And to make the install-script and service unit files up to date before every update, I use a script to fetch the latest install-script from the repository to my machine and then start the install-script automatically, worked fine.

Then when I tried to update the V2Ray to 4.27.5, something went wrong.
I started to receive error messages from the machine's COM console when I tried to start it (and really failed to start):

Sep  5 19:41:02 ogonj-0 v2ray[19823]: V2Ray 4.27.5 (V2Fly, a community-driven edition of V2Ray.) Custom (go1.14.7 linux/amd64)
Sep  5 19:41:02 ogonj-0 maintainence.sh[19102]: info: Start the V2Ray service.
Sep  5 19:41:02 ogonj-0 v2ray[19823]: A unified platform for anti-censorship.
Sep  5 19:41:02 ogonj-0 v2ray[19823]: main: failed to read config files: [/usr/local/etc/v2ray/config.json] > v2ray.com/core/main/json: failed to execute v2ctl to convert config file. > v2ray.com/core/common/platform/ctlcmd: failed to execute v2ctl:
Sep  5 19:41:02 ogonj-0 v2ray[19823]: v2ctl> Read config:  /usr/local/etc/v2ray/config.json
Sep  5 19:41:02 ogonj-0 v2ray[19823]: panic: open /usr/local/etc/v2ray/config.json: no such file or directory
Sep  5 19:41:02 ogonj-0 v2ray[19823]: goroutine 1 [running]:
Sep  5 19:41:02 ogonj-0 v2ray[19823]: v2ray.com/core/common.Must(...)
Sep  5 19:41:02 ogonj-0 v2ray[19823]: #011v2ray.com/core/common/common.go:26
Sep  5 19:41:02 ogonj-0 v2ray[19823]: v2ray.com/core/infra/control.(*ConfigCommand).Execute(0x104f9b0, 0xc0000301a0, 0x1, 0x1, 0xc00019c2e8, 0xcf59bf1808aea901)
Sep  5 19:41:02 ogonj-0 v2ray[19823]: #011v2ray.com/core/infra/control/config.go:42 +0x673
Sep  5 19:41:02 ogonj-0 v2ray[19823]: main.main()
Sep  5 19:41:02 ogonj-0 v2ray[19823]: #011v2ray.com/core/infra/control/main/main.go:35 +0x217 > exit status 2

Of course it could not find the config file because I use multiple config files so no config.json there.

But it worked fine before:

Aug 29 03:54:50 ogonj-0 v2ray[12408]: V2Ray 4.27.4 (V2Fly, a community-driven edition of V2Ray.) Custom (go1.14.7 linux/amd64)
Aug 29 03:54:50 ogonj-0 v2ray[12408]: A unified platform for anti-censorship.
Aug 29 03:54:50 ogonj-0 v2ray[12408]: 2020/08/29 03:54:50 Using confdir from arg: /usr/local/etc/v2ray/
Aug 29 03:54:51 ogonj-0 v2ray[12408]: 2020/08/29 03:54:51 [Info] v2ray.com/core/common/platform/ctlcmd: <v2ctl message>
Aug 29 03:54:51 ogonj-0 v2ray[12408]: v2ctl> Read config:  /usr/local/etc/v2ray/00_log.json
Aug 29 03:54:51 ogonj-0 v2ray[12408]: v2ctl> Read config:  /usr/local/etc/v2ray/01_api.json
Aug 29 03:54:51 ogonj-0 v2ray[12408]: v2ctl> Read config:  /usr/local/etc/v2ray/02_dns.json
Aug 29 03:54:51 ogonj-0 v2ray[12408]: v2ctl> Read config:  /usr/local/etc/v2ray/03_routing.json
Aug 29 03:54:51 ogonj-0 v2ray[12408]: v2ctl> Read config:  /usr/local/etc/v2ray/04_policy.json
Aug 29 03:54:51 ogonj-0 v2ray[12408]: v2ctl> Read config:  /usr/local/etc/v2ray/05_inbounds.json
Aug 29 03:54:51 ogonj-0 v2ray[12408]: v2ctl> Read config:  /usr/local/etc/v2ray/06_outbounds.json
Aug 29 03:54:51 ogonj-0 v2ray[12408]: v2ctl> Read config:  /usr/local/etc/v2ray/07_transport.json
Aug 29 03:54:51 ogonj-0 v2ray[12408]: v2ctl> Read config:  /usr/local/etc/v2ray/08_stats.json
Aug 29 03:54:51 ogonj-0 v2ray[12408]: v2ctl> Read config:  /usr/local/etc/v2ray/09_reverse.json
Aug 29 03:54:51 ogonj-0 v2ray[12408]: 2020/08/29 03:54:51 [Warning] v2ray.com/core: V2Ray 4.27.4 started

When I tried to reinstall the older version it could not work anymore too.

Then I found the service unit file has changed like this:

[Unit]
Description=V2Ray Service
After=network.target nss-lookup.target
[Service]
User=nobody
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
NoNewPrivileges=true
Environment=V2RAY_LOCATION_ASSET=/usr/local/share/v2ray/
ExecStart=/usr/local/bin/v2ray -config /usr/local/etc/v2ray/config.json
Restart=on-failure
[Install]
WantedBy=multi-user.target

The config path should be a config directory before. It seems a change broke the compatibility.

Is this change is an accidental change or an intended change for some reasons?

你们这里安装的v2ray不要求服务器是北京时间了?

你们这里安装的v2ray不要求服务器是北京时间了?
系统:Amazon linux 2 AMI

   __|  __|_  )
   _|  (     /   Amazon Linux 2 AMI
  ___|\___|___|

https://aws.amazon.com/amazon-linux-2/
[ec2-user@ip-10-0-0-242 ~]$ cat /etc/sysconfig/clock
ZONE="UTC"
UTC=true
[ec2-user@ip-10-0-0-242 ~]$ date -R
Tue, 08 Sep 2020 08:57:05 +0000
[ec2-user@ip-10-0-0-242 ~]$ v2ray --version
V2Ray 4.27.5 (V2Fly, a community-driven edition of V2Ray.) Custom (go1.14.7 linux/amd64)
A unified platform for anti-censorship.
[ec2-user@ip-10-0-0-242 ~]$

install error

i don`t find the config.json at /etc/v2ray . but i installed it successfully. help me
image

换新安装方式后原兼容ss+v2ray-plugin的配置文件运行不了

原来使用go.sh的时候同样的配置是可以运行的,换成新脚本安装后就不行了,systemctl status v2ray显示如下:

v2ray.service - V2Ray Service
   Loaded: loaded (/etc/systemd/system/v2ray.service; disabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Mon 2020-06-22 06:20:39 UTC; 621ms ago
  Process: 2513 ExecStart=/usr/local/bin/v2ray -confdir /usr/local/etc/v2ray/ (code=exit
 Main PID: 2513 (code=exited, status=255/EXCEPTION)

Jun 22 06:20:39 test systemd[1]: v2ray.service: Main process exited, code=exited, status
Jun 22 06:20:39 test systemd[1]: v2ray.service: Failed with result 'exit-code'.
Jun 22 06:20:39 test systemd[1]: v2ray.service: Service RestartSec=100ms expired, schedu
Jun 22 06:20:39 test systemd[1]: v2ray.service: Scheduled restart job, restart counter i
Jun 22 06:20:39 test systemd[1]: Stopped V2Ray Service.
Jun 22 06:20:39 test systemd[1]: v2ray.service: Start request repeated too quickly.
Jun 22 06:20:39 test systemd[1]: v2ray.service: Failed with result 'exit-code'.
Jun 22 06:20:39 test systemd[1]: Failed to start V2Ray Service.

我的config如下:

{
  "log" : {
    "access": "/var/log/v2ray/access.log",
    "error": "/var/log/v2ray/error.log",
    "loglevel": "warning"
  },
  "inbounds": [{
    "port": 51515,
    "listen": "127.0.0.1",
    "protocol": "vmess",
    "settings": {
      "clients": [
        {
          "id": "uuid",
          "level": 1,
          "alterId": 64
        }
      ]
    },
    "streamSettings":{
      "network": "ws",
      "wsSettings": {
           "path": "/forv2r"
      }
    }
  },
  {
    "port": "51516",
    "listen": "127.0.0.1",
    "protocol": "dokodemo-door",
    "tag": "ssvr",
    "settings": {
      "address": "v1.mux.cool",
      "followRedirect": false,
      "network": "tcp"
    },
    "streamSettings": {
      "network": "ws",
      "wsSettings": {
      "path": "/forss"
      }
    }
  },
  {
    "port": 9015,
    "protocol": "shadowsocks",
    "settings": {
      "method": "aes-256-gcm",
      "ota": false,
      "password": "123456",
      "network": "tcp,udp"
    },
    "streamSettings": {
      "network": "domainsocket"
    }
  }],
  "outbounds": [{
      "protocol": "freedom",
      "settings": {},
      "tag": "direct"
    },
    {
      "protocol": "blackhole",
      "settings": {},
      "tag": "blocked"
    },
    {
      "protocol": "freedom",
      "tag": "ss",
      "streamSettings": {
        "network": "domainsocket"
      }
    }
  ],
  "transport": {
    "dsSettings": {
      "path": "/var/run/ss-loop.sock"
    }
  },
  "routing": {
    "rules": [
      {
        "type": "field",
        "inboundTag": [
          "ssvr"
        ],
        "outboundTag": "ss"
      },
      {
        "type": "field",
        "ip": [
          "geoip:private"
        ],
        "outboundTag": "blocked"
      }
    ]
  }
}

前面套了nginx,不同域名可以对应使用v2ray和ss+plugin客户端。
已经试过4.25.0版本下,使用go.sh安装是可以运行的,使用fhs安装就会出现开头的情况

建议配置文件添加默认配置

配置文件分散开来后,确实方便点,不像以前那么冗长一直上下翻来翻去,但目前默认都是空的,不方便新手添加配置。

建议一:添加默认配置格式

把各个配置文件添加上默认配置,用户就可以直接在上面按原来的格式修改,这样不容易出错。需要高级用法再去查文档

建议二:v2ray考虑支持一下yaml

json格式很坑,注释也不方便,虽然现在支持注释,但标准json是不支持的,我们没法用json检测工具去检测有注释的json,因为那样肯定报错,但每次把注释删除再检测又很麻烦,而有时候又确实需要注释,而且就算不用注释,用yaml也没json那么坑,所以不知道v2ray有没有考虑过支持一下yaml。

Ansible Rule

I have created an ansible rule based on this script here. I am glad to hear your opinions about it.

stop_v2ray 对于首次安装逻辑处理有问题

首次安装的时候systemd并没有v2ray服务,这就导致了systemctl stop v2ray的返回代码不是0,导致脚本中止运行。
建议在[[ -z "$V2RAY_CUSTOMIZE" ]]增加一个判断条件,判断v2ray服务是否存在。

“简繁体之争” 的一些建议和要求

重视彼此的想法、风格和观点。我们也许并不总是能够达成共识,但意见分歧绝非无礼的借口。请对不同的可能性和错误持开放态度。尤其是在讨论不同选择的优劣时,应在所有的交流和沟通中保持尊重。要意识到您的影响以及强烈的互动可能会影响到他人。 -moz://a

我们的目标不应该是“吵赢别人”或排挤其他不同的观点。

关于语言,我们可以直接使用 ISO 3166 这一广泛使用的标准。使用文化和文字习惯来分类,而不是国家和民族/地区等。

使用国旗是一个危险的操作,国旗作为一种政治符号。 而 V2Fly 作为一个被政府注意的项目,把政治倾向和风险加到团队每个人身上,严重危害了人身安全。

隐私和安全是我们的底线,不能被挑战。

[ABUSE]

换脚本不说,里面config文件空的,我还自己写 你升级了什么?你这是在破解使用体验 作为普通用来说太麻烦了 并没有原脚本易用

stuck at the final step: # v2ray --config=/usr/local/etc/v2ray/config.json

Hi developer:
Currently, I follow all the steps on the instructions and using v2ray 4.27.5 in centos7. When I run:
[root@nice-silo-1 ~]# v2ray --config=/usr/local/etc/v2ray/config.json
I got:

V2Ray 4.27.5 (V2Fly, a community-driven edition of V2Ray.) Custom (go1.14.7 linux/amd64)
A unified platform for anti-censorship.
2020/09/02 21:38:59 [Info] v2ray.com/core/common/platform/ctlcmd:
v2ctl> Read config: /usr/local/etc/v2ray/config.json
2020/09/02 21:38:59 [Warning] v2ray.com/core: V2Ray 4.27.5 started
[cursor on here]

and the cursor is always on and at the final line, resulting in v2ray service not starting.

新版安装脚本安装后用systemctl不能启动,命令行正常。

最近把v2迁移到新的安装脚本环境中,试着用命令行 test了一下,一切正常。然而用systemctl start/restart 都提示failed to start v2ray service 。用journalctl -u v2ray 也没有发现什么有用的信息。现在暂时用
/usr/local/bin/v2ray -confdir /usr/local/etc/v2ray &
应付着

Centos7 下 V2ray 服务启动无法读取证书 ,直接命令行启动正常

Aug 04 03:58:27 VM-4-12-centos v2ray[1797]: V2Ray 4.26.0 (V2Fly, a community-driven edition of V2Ray.) Custom (go1.14.4 linux/amd64)
Aug 04 03:58:27 VM-4-12-centos v2ray[1797]: A unified platform for anti-censorship.
Aug 04 03:58:27 VM-4-12-centos v2ray[1797]: main: failed to read config files: [/etc/v2ray/config.json] > v2ray.com/core/main/json: failed to execute v2ctl
Aug 04 03:58:27 VM-4-12-centos v2ray[1797]: v2ctl> Read config:  /etc/v2ray/config.json
Aug 04 03:58:27 VM-4-12-centos v2ray[1797]: v2ray.com/core/infra/conf: Failed to build TLS config. > v2ray.com/core/infra/conf: failed to parse certificate > open /www/server/panel/vhost/cert/xxxxx/fullchain.pem: permission denied > exit status 255
Aug 04 03:58:27 VM-4-12-centos systemd[1]: v2ray.service: main process exited, code=exited, status=23/n/a
Aug 04 03:58:27 VM-4-12-centos systemd[1]: Unit v2ray.service entered failed state.
Aug 04 03:58:27 VM-4-12-centos systemd[1]: v2ray.service failed.
Aug 04 03:58:27 VM-4-12-centos systemd[1]: v2ray.service holdoff time over, scheduling restart.
Aug 04 03:58:27 VM-4-12-centos systemd[1]: Cannot add dependency job for unit rpcbind.socket, ignoring: Unit not found.
Aug 04 03:58:27 VM-4-12-centos systemd[1]: Stopped V2Ray Service.
-- Subject: Unit v2ray.service has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit v2ray.service has finished shutting down.
Aug 04 03:58:27 VM-4-12-centos systemd[1]: start request repeated too quickly for v2ray.service
Aug 04 03:58:27 VM-4-12-centos systemd[1]: Failed to start V2Ray Service.
-- Subject: Unit v2ray.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit v2ray.service has failed.
--
-- The result is failed.
Aug 04 03:58:27 VM-4-12-centos systemd[1]: Unit v2ray.service entered failed state.
Aug 04 03:58:27 VM-4-12-centos systemd[1]: v2ray.service failed.

certs:

-rw------- 1 root root 3552 Aug  4 03:09 fullchain.pem
-rw------- 1 root root 1704 Aug  4 03:09 privkey.pem

/etc/systemd/system/v2ray.service

[Unit]
Description=V2Ray Service
Documentation=https://www.v2ray.com/ https://www.v2fly.org/
After=network.target nss-lookup.target

[Service]
# If the version of systemd is 240 or above, then uncommenting Type=exec and commenting out Type=simple
#Type=exec
Type=simple
# This service runs as root. You may consider to run it as another user for security concerns.
# By uncommenting User=nobody and commenting out User=root, the service will run as user nobody.
# More discussion at https://github.com/v2ray/v2ray-core/issues/1011
User=root
#User=nobody
CapabilityBoundingSet=CAP_NET_RAW CAP_NET_ADMIN CAP_NET_BIND_SERVICE
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
NoNewPrivileges=true
ExecStart=/usr/bin/v2ray/v2ray -config /etc/v2ray/config.json
Restart=on-failure

[Install]
WantedBy=multi-user.target

id nobody

uid=99(nobody) gid=99(nobody) groups=99(nobody)

但是直接命令行以root 运行就没有问题了

【提问前请先阅读】以 #61 为例的临时 FAQ

  1. 你希望别人在你的 Issue 上花多少时间,就请自己先在自己的 Issue 上花多少时间。
  2. 技术提问通常适用一个黄金比例:七分解释、三分提问。别忘了沟通技术问题最重要也是最困难的一点就是重现环境。
    通篇连环提问其实是在要求对方心电感应你遇到的情况——很少有问题能在这样的限制下得到很好的解答。

这个 Issue 实在是极具教学意义,所以直接让我打消了写一篇经过整理的 FAQ 的想法。
首先是 《提问的智慧》镇楼,知道每个来提问的人的时间都很宝贵,所以不要求第一次提问前就阅读。
不过在等待他人给您提供解答的这段足够长的时间里,请多读一读这篇文章,说不定你会马上希望自己趁脸还没有丢大之前回去修改刚刚发布的 Issue。

  1. 对于初次使用安装脚本的用户,您可能是需要从旧版安装脚本迁移至此的一批,请参阅:Wiki-从旧脚本迁移至此

  2. 如果您之前没有安装过 v2ray,或者已经卸载了将要重装,请参阅:官方文档-Linux 安装脚本

  3. docker 镜像构建问题
    构建 docker 镜像的思路是自己来做 v2ray 官方在发布新版本时打包的流程,而不是在 docker 镜像里执行安装脚本安装 v2ray。所以涉及到自定义构建 docker 镜像的问题请不要来该仓库寻求帮助。
    另外如果你只是不知道 v2fly 官方有在发布 docker 镜像,那么你可以参考 #75

至于你说 docker 镜像的问题,v2ray 官方有提供 docker 镜像发布,在这里:hub.docker.com/r/v2fly/v2fly-core
如果你需要自定义,该 仓库 的 dockerfile 也可以供你参考和修改。所以我看不出你来这里寻求帮助的意义。

  1. 我不管我就是想要旧版的安装脚本
    参考 #86

https://github.com/v2ray/v2ray-core/blob/e65c3930171a9073299f3e960f549722d18899a2/release/install-release.sh

至于你要怎么改让这个脚本可以 work 那就是你的事了,不改肯定不能 work。本项目暂时无计划为这部分用户提供支持,所以请不要浪费时间在 issue 区 troll。


如果您照着上面给出的指南操作还是遇到了问题,请在发布 Issue 时注意以下几点:
#61 (comment)

不要把 issue 当成聊天一样的用,还有贴错误日志的时候用 ``` 比截图更加友好。

遇到问题先
journalctl --boot -u v2ray
V2RAY_LOCATION_ASSET=/usr/local/share/v2ray/ v2ray -test -confdir /usr/local/etc/v2ray/
ls -alF --color=auto /usr/local/etc/v2ray
systemd-analyze cat-config /etc/systemd/system/v2ray.service
systemd-analyze verify /etc/systemd/system/v2ray.service
五连,把输出用 ``` 包裹起来发上来。

如果您顺利地走完了安装过程,接下来您可能会遇到的问题有:

  1. 证书权限问题
    症状请参考 #59,解决方法请参考:Wiki-使用证书时权限不足

  2. 配置文件为空
    #61 (comment)
    这不是一个 bug。

fhs-install-v2ray 从一开始创建的配置文件就是空的,不会像现在已经被废除的旧安装脚本那样为用户创建一套开箱即用的配置。
我认为 v2ray 这样的项目确实也没有默认配置可言,请用户不要再将这件事作为 bug 提交上来,你们既然选择自建,就应该自己写自己的配置了。
过程中遇到任何问题,请参阅 v2fly.org。

  1. 其他问题
    我暂时没看到适合拿来做例子的 Issue,但你遇到的问题通常在你彻底读完 README 后就已经得到了解答。如果您看到这里开始后悔自己没有先看完 README 再来到 Issue 区,这里是 后悔药

非 root 用户使用 sudo 运行时报错

sudo bash <(curl -sL https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh) 会报 bash: /dev/fd/63: No such file or directory 这个错,造成无法顺利安装

包管理器的判断缺陷导致 arch 系使用此脚本报错

manjaro 使用此脚本时报错 The script does not support the package manager in this operating system,而旧版 go.sh 虽然判断方式类似,但仍可进行安装流程。目前只能将脚本下载至本地,并删除
if [[ "$(command -v apt)" ]]; then
PACKAGE_MANAGEMENT_INSTALL='apt install'
PACKAGE_MANAGEMENT_REMOVE='apt remove'
elif [[ "$(command -v yum)" ]]; then
PACKAGE_MANAGEMENT_INSTALL='yum install'
PACKAGE_MANAGEMENT_REMOVE='yum remove'
if [[ "$(command -v dnf)" ]]; then
PACKAGE_MANAGEMENT_INSTALL='dnf install'
PACKAGE_MANAGEMENT_REMOVE='dnf remove'
fi
elif [[ "$(command -v zypper)" ]]; then
PACKAGE_MANAGEMENT_INSTALL='zypper install'
PACKAGE_MANAGEMENT_REMOVE='zypper remove'
else
echo "error: The script does not support the package manager in this operating system."
exit 1
部分才能成功使用。

新版脚本不再默认生成服务端配置,且配置文件结构完全不同

https://www.v2ray.com/ 等网站完全按照旧版脚本介绍。而新版脚本不再默认生成服务端配置,且配置文件夹/usr/local/etc/v2ray/中默认有9个json文件:
00_log.json 02_dns.json 04_policy.json 06_outbounds.json 08_stats.json
01_api.json 03_routing.json 05_inbounds.json 07_transport.json 09_reverse.json
尝试将旧版中的“inbounds”项直接写入05_inbounds.json文件,重启服务后仍无法连接(已停止防火墙)。

请允许保留旧版脚本一段时间,直至主要教程更新。

建议安装时初始化 log 配置及预创建日志文件(nobody)

另一个建议:运行脚本时若检测到 /var/log/v2ray/ 目录下已有文件,则更改全部文件所属的用户和组。

因 nobody 对日志文件的权限不够而导致 v2ray 无法启动是一个很常见又隐蔽的坑,若非更换脚本,则通常是因为用户先用更高的权限手动测试时先创建了日志文件。这两个建议可以在很大程度上降低这个问题的出现概率。

对当前项目的一点建议

  1. 目前项目中 geoip.dat 和 geosite.dat 的放置位置并不够准确,因为 geoip.dat 和 geosize.dat 属于架构无关的文件,所以它们应该在 /usr/loacl/share/v2ray
    lib
    share

  2. 希望在 After= 增加 network-online.target
    为什么要把这个扔掉的选项加回来?因为我发现这个选项对客户端与转发是有用处的
    意在不会出现网络并没有准备好但是还是会启动 v2ray 导致一些可能的问题

添加force local install参数

如题。譬如在反向代理情景中,要更新内网设备(家用宽带)的V2Ray时十分困难,一来github下载严重延迟,二来如果操作失误就完全无法通过远端访问内网设备。

一些操作失误的例子如下

  1. 通过--local 参数更新V2Ray会因systemctl stop v2ray命令运行后断掉SSH远端访问,后续命令无法执行

  2. 通过添加 /root/install-release.sh --local v2ray.zip到/etc/rc.local,然后reboot重新更新也失败,无法通过SSH远端访问内网设备(虽然最后靠断电重新开启设备暂时解决了)

故此,希望能添加force local install参数,在忽略任何警告情况以及不中断下运行install-release.sh,更新v2ray

能支持Ubuntu 14.04的安装吗

很久没有折腾服务器了,今天折腾一下,发现官方的go.sh脚本不能被弃用了,跳转到了这个项目。但是这个项目只能支持systemd的安装,我一直使用的Ubuntu 14的系统,突然就没有官方支持了。不知项目能够支持Ubuntu 14的安装吗?

/usr/local/lib/v2ray 不存在

在某些情况下,似乎不会建立这个目录,也不会放入 geoip.dat 和 geosite.dat,造成 v2ray 启动出错。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.