v2fly / fhs-install-v2ray

Bash script for installing V2Ray in operating systems such as Debian / CentOS / Fedora / openSUSE that support systemd
GNU General Public License v3.0
6.28k stars 1.45k forks source link

无法安装为多配置文件模式 #168

Closed liansh2002 closed 4 years ago

liansh2002 commented 4 years ago

114 中提到的安装脚本以及master和develop都试了,安装后依然是单配置文件模式。

测试平台x86_64,Debian,安装前已使用脚本删除(--remove)并重启系统。安装过程如下:

xxxx@debian:~/app/fhs-install-v2ray$ $JSONS_PATH -bash: /usr/local/etc/v2ray: Is a directory

xxxx@debian:~/app/fhs-install-v2ray$ proxychains4 sudo bash ./install-release.sh [proxychains] config file found: /etc/proxychains.conf [proxychains] preloading /usr/lib/libproxychains4.so info: Installing V2Ray v4.31.0 for x86_64 Downloading V2Ray archive: https://github.com/v2fly/v2ray-core/releases/download/v4.31.0/v2ray-linux-64.zip % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 644 100 644 0 0 710 0 --:--:-- --:--:-- --:--:-- 710 100 11.9M 100 11.9M 0 0 297k 0 0:00:40 0:00:40 --:--:-- 382k Downloading verification file for V2Ray archive: https://github.com/v2fly/v2ray-core/releases/download/v4.31.0/v2ray-linux-64.zip.dgst info: Extract the V2Ray package to /tmp/tmp.waKJMm93Nu and prepare it for installation. rm: cannot remove '/etc/systemd/system/v2ray.service.d/10-donot_touch_multi_conf.conf': No such file or directory rm: cannot remove '/etc/systemd/system/v2ray@.service.d/10-donot_touch_multi_conf.conf': No such file or directory info: Systemd service files have been installed successfully! warning: The following are the actual parameters for the v2ray service startup. warning: Please make sure the configuration file path is correctly set.

/etc/systemd/system/v2ray.service

[Unit] Description=V2Ray Service Documentation=https://www.v2fly.org/ 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 ExecStart=/usr/local/bin/v2ray -config /usr/local/etc/v2ray/config.json Restart=on-failure RestartPreventExitStatus=23

[Install] WantedBy=multi-user.target

/etc/systemd/system/v2ray.service.d/10-donot_touch_single_conf.conf

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 /usr/local/etc/v2ray/config.json 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: /etc/systemd/system/v2ray.service installed: /etc/systemd/system/v2ray@.service removed: /tmp/tmp.waKJMm93Nu info: V2Ray v4.31.0 is installed. You may need to execute a command to remove dependent software: apt purge curl unzip Please execute the command: systemctl enable v2ray; systemctl start v2ray

IceCodeNew commented 4 years ago

你的执行方式有问题,试试 export JSONS_PATH='/usr/local/etc/v2ray' && bash <(curl -sSL https://raw.githubusercontent.com/IceCodeNew/fhs-install-v2ray/master/install-release.sh)

IceCodeNew commented 4 years ago

我怀疑 proxychains4 在这里会形成相当的干扰,如果你的环境上需要使用代理,请传递 -x proxy_protocol://ip.ip.ip.ip:port 给脚本,不要用 proxychains4

liansh2002 commented 4 years ago

感谢解答,问题已解。因为权限问题使用sudo执行脚本,但sudo并没有继承当前用户的环境变量导致(参考How to export variable for use with sudo?。最终解决方法如下: sudo JSONS_PATH=/usr/local/etc/v2ray bash ./install-release.sh