【建议】增加用户级别的 xray.service 支持 #55

Open
opened 2023-03-15 13:08:02 -04:00 by ytxmobile98 · 1 comment
ytxmobile98 commented 2023-03-15 13:08:02 -04:00 (Migrated from github.com)

目前这个脚本安装的 xray.service 只能安装到系统的 systemctl service 目录,对于不便或者不能使用 root 的场景没有很好的支持,此外在多用户场景下也使得不同用户被迫共享同一个配置文件,体验并不好。

由于 systemd 本身是有运行 user unit 的功能的,因此我在自己的电脑上,通过复制粘贴的方式,写了一个用户级 xray.service 给我自己使用,内容如下:

[Unit]
Description="Xray service (user unit)"

[Service]
ExecStart="%h/GFW/Xray/Xray-linux-64/xray" -c "%h/GFW/Xray/Xray-linux-64/config.json"
Restart=on-failure
RestartPreventExitStatus=23
LimitNPROC=10000
LimitNOFILE=1000000

[Install]
WantedBy=default.target

按照 systemd.unit(5) manpage 的说明,我把它放到了 ~/.config/systemd/user 目录。

然后就可以在 systemd 命令中传入 --user 来启动了:

  • 立即启动:systemctl start --user xray
  • 登录时启动:systemctl enable --user xray

希望作者更新一下安装脚本,在日后以非 root 权限安装的时候能够用上这个功能。

目前这个脚本安装的 `xray.service` 只能安装到系统的 systemctl service 目录,对于不便或者不能使用 root 的场景没有很好的支持,此外在多用户场景下也使得不同用户被迫共享同一个配置文件,体验并不好。 由于 systemd 本身是有运行 user unit 的功能的,因此我在自己的电脑上,通过复制粘贴的方式,写了一个用户级 `xray.service` 给我自己使用,内容如下: ```service [Unit] Description="Xray service (user unit)" [Service] ExecStart="%h/GFW/Xray/Xray-linux-64/xray" -c "%h/GFW/Xray/Xray-linux-64/config.json" Restart=on-failure RestartPreventExitStatus=23 LimitNPROC=10000 LimitNOFILE=1000000 [Install] WantedBy=default.target ``` 按照 `systemd.unit(5)` manpage 的说明,我把它放到了 `~/.config/systemd/user` 目录。 然后就可以在 `systemd` 命令中传入 `--user` 来启动了: * 立即启动:`systemctl start --user xray` * 登录时启动:`systemctl enable --user xray` **希望作者更新一下安装脚本,在日后以非 root 权限安装的时候能够用上这个功能。**
ghost commented 2023-04-05 15:27:05 -04:00 (Migrated from github.com)

自从添加对应的用户就可以了

自从添加对应的用户就可以了
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
XTLS/Xray-install#55
No description provided.