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

Open
#55 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
63/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
linux, shell
Domain
devops

Research direction

Read the installation script and find where it creates or installs xray.service and chooses the system service directory. Compare that flow with the user unit example in the issue, including its ~/.config/systemd/user location and systemctl --user commands. Done means the installer supports installing the service for a non-root user while preserving the existing system service path.

Written by the indexing model from the issue text.

Description

PR welcome

目前这个脚本安装的 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 权限安装的时候能够用上这个功能。

Dominant language
Shell
Stars
3.7k
Forks
663
Avg merge
1d 17h
Merged PRs (30d)
2

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from XTLS/Xray-install

All issues in XTLS/Xray-install

Similar issues

More Shell/Bash issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.