fhs-install-v2ray
fhs-install-v2ray copied to clipboard
v2ray.service.d 设计可能误导
systemd 配置应该和其他发行版包文件保持一致,如果有修改应该讨论统一修改
a). 尽管对于所有安装场景,本项目都会添加 drop-in 配置,但这个配置在用户没有设置环境变量进行自定义时,是和发行版包文件里内容一致的。 b). 安装过程中有特意强调出来的提示告知用户检查 drop-in 配置是否符合需要 https://github.com/v2fly/fhs-install-v2ray/blob/804e5e3788a6770b3111f9ad01dd81101b0997d4/install-release.sh#L356-L380
cons on a): 如果更新不及时,就会给不打算自定义安装参数的用户带去困扰。 但其实这里设计时我也头疼过很久,最开始我是判断环境变量是否存在,如果存在是否与项目默认安装位置相等,结合两个判断才去创建 drop-in 配置。但后来一想,发现如果上游改变默认安装位置,但不提前通知本项目的维护成员,那同样会发生在不必要创建 drop-in 配置时创建 drop-in 配置的情况。 所以最后就挑最简单的来实现了,但是提前在安装时给足用户提示。
如果是为了提示,为什么不直接把 systemd 文件打印出来呢
你说到 systemd 配置应该和其他发行版包文件保持一致,其实这里是做到了的才对。 从实际出发,上游不定时改变 systemd 配置文件这一点是本项目应该预期的。所以有必要在安装时更新已经存在的 systemd 配置文件。 但是这样一来很多用户选择自定义 systemd 配置文件的,又会遇到每次使用脚本升级都丢失自己修改的问题。 我确实认为这两个问题都是本项目必须解决的问题,而且认为同时解决这两个问题非 drop-in 配置不可。如果你有更好的提议,欢迎告诉我。
如果是为了提示,为什么不直接把 systemd 文件打印出来呢
你再往下面多读几行……
我认为应该停止更新已经存在的 systemd 配置。 更新 systemd 配置并不是一个经常出现的问题,5年来也只改过一次,并经过6个多月的通知。 使用其他方案来解决这个问题,只会变得更加复杂。
我认为应该停止更新已经存在的 systemd 配置。
参考包管理器的做法嘛 apt 是问你要不要覆盖,pacman 是写到 .pacnew 文件里去。脚本跑到一半问用户个问题~~又不会死~~
I support either asking permission to overwrite or not overwriting at all. In fact, I don't know any other Linux software that overwrites config files already changed by user.
Also, the "hint for users" in its current form doesn't make any sense. I've read it over and over and still can't figure out what "Duplicate this file in the same directory and make your customizes there" means. Which directory is the "same directory"? How can you ever duplicate a file in the same directory (under the same file name)?
能否加一个 --keep-service-file 参数,当带有这个参数运行的时候会跳过install_startup_service_file() 这个函数?
能否加一个 --keep-service-file 参数,当带有这个参数运行的时候会跳过install_startup_service_file() 这个函数?
可。
I still think the install script should act the way all (or at least most) install script on Linux do:
- Test if an existing service file has been changed by user;
- If unchanged, update it;
- If changed, ask the user if they want to update;
- If update, rename the existing one to
something.origand comment it out by putting a#at the start of every line; - If not update, install the new default service file as
something.newand comment it out by putting a#at the start of every line.
I still think the install script should act the way all (or at least most) install script on Linux do:
- Test if an existing service file has been changed by user;
- If unchanged, update it;
- If changed, ask the user if they want to update;
- If update, rename the existing one to
something.origand comment it out by putting a#at the start of every line;- If not update, install the new default service file as
something.newand comment it out by putting a#at the start of every line.
It is not as simple as you think. BTW PR welcomed.
反正我每次更新前,都把先找出我之前修改好的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 -confdir /usr/local/etc/v2ray/
Restart=on-failure
RestartPreventExitStatus=23
[Install]
WantedBy=multi-user.target
用这个脚本安装后,我马上去修改v2ray.service文件,把我自己的配置覆盖上去,并且把service.d中的那个donot_touch_single_conf.conf文件添加一个.bak,意思就是我不用它。另外我也希望,重复安装(其实就是为了更新)时,不要覆盖我之前的文件,不然每次我都要去修改。
可能我linux不太熟悉吧,我一直不太清楚添加了@有什么不一样
drwxr-xr-x 2 root root 4.0K Aug 19 16:13 v2ray.service.d
drwxr-xr-x 2 root root 4.0K Dec 10 2020 [email protected]
我打开两个文件看内容都是一样的,就算之前没有service.d的时候,也是有 v2ray.service和 [email protected],有人能解释一下吗?这个@是一个业界标准,还是说只是为了区分单文件和多文件启动?我写成“v2ray2”是不是一样可以??因为这个名字其实就是我重启的时候,用systemctl restart v2ray@还是systemctl restart v2ray2的问题,我想知道这个@是不是就是一个普通字符呢?还是linux标准呢?
另外,关于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/%i.json
这个%i看上去是多配置文件的时候,把每个配置文件都启动一遍??另外为什么有两个ExecStart,并且其中一个是空的?
可是我直接用-configdir指定,也可以启动多配置文件方式呀
ExecStart=/usr/local/bin/v2ray -confdir /usr/local/etc/v2ray/
反正我每次更新前,都把先找出我之前修改好的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 -confdir /usr/local/etc/v2ray/ Restart=on-failure RestartPreventExitStatus=23 [Install] WantedBy=multi-user.target用这个脚本安装后,我马上去修改v2ray.service文件,把我自己的配置覆盖上去,并且把service.d中的那个donot_touch_single_conf.conf文件添加一个.bak,意思就是我不用它。另外我也希望,重复安装(其实就是为了更新)时,不要覆盖我之前的文件,不然每次我都要去修改。
可能我linux不太熟悉吧,我一直不太清楚添加了
@有什么不一样drwxr-xr-x 2 root root 4.0K Aug 19 16:13 v2ray.service.d drwxr-xr-x 2 root root 4.0K Dec 10 2020 [email protected]我打开两个文件看内容都是一样的,就算之前没有service.d的时候,也是有 v2ray.service和 [email protected],有人能解释一下吗?这个
@是一个业界标准,还是说只是为了区分单文件和多文件启动?我写成“v2ray2”是不是一样可以??因为这个名字其实就是我重启的时候,用systemctl restart v2ray@还是systemctl restart v2ray2的问题,我想知道这个@是不是就是一个普通字符呢?还是linux标准呢?另外,关于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/%i.json这个
%i看上去是多配置文件的时候,把每个配置文件都启动一遍??另外为什么有两个ExecStart,并且其中一个是空的? 可是我直接用-configdir指定,也可以启动多配置文件方式呀ExecStart=/usr/local/bin/v2ray -confdir /usr/local/etc/v2ray/
你这里面抛的问题很多都可以自己上网查到,你直接拿过来问我是浪费我的时间。我很感谢你愿意参与到项目发展中,提出你自己的意见,但是你需要珍惜其他人的时间,这是一种尊重。 这个 issue 最开始是项目维护者之间讨论某个设计是否合理,如何完善。因为意见不能统一所以一直搁置。从这一点来说,你不该在这个 issue 上提问你想了解的 Linux 知识,或者分享你自己的使用方式,这些都是跑题。