Browse Source

feat: New systemd unit file

1. Add systemd/system/v2ray.service .
2. Add systemd/system/v2ray@.service .
3. Modify the installation path in the BUILD file.

issue v2fly/fhs-install-v2ray#53
pull/2714/head
Dct Mei 4 years ago
parent
commit
3e612d899c
No known key found for this signature in database
GPG Key ID: 50BF8B712DCAD7EA
  1. 3
      release/BUILD
  2. 16
      release/config/systemd/system/v2ray.service
  3. 16
      release/config/systemd/system/v2ray@.service
  4. 22
      release/config/systemd/v2ray.service
  5. 22
      release/config/systemd/v2ray@.service

3
release/BUILD

@ -15,7 +15,8 @@ filegroup(
filegroup(
name = "systemd",
srcs = [
"config/systemd/v2ray.service",
"config/systemd/system/v2ray.service",
"config/systemd/system/v2ray@.service",
],
)

16
release/config/systemd/system/v2ray.service

@ -0,0 +1,16 @@
[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
Environment=V2RAY_LOCATION_ASSET=/usr/local/share/v2ray/
ExecStart=/usr/local/bin/v2ray -confdir /usr/local/etc/v2ray/
Restart=on-failure
[Install]
WantedBy=multi-user.target

16
release/config/systemd/system/v2ray@.service

@ -0,0 +1,16 @@
[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
Environment=V2RAY_LOCATION_ASSET=/usr/local/share/v2ray/
ExecStart=/usr/local/bin/v2ray -config /usr/local/etc/v2ray/%i.json
Restart=on-failure
[Install]
WantedBy=multi-user.target

22
release/config/systemd/v2ray.service

@ -1,22 +0,0 @@
[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_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

22
release/config/systemd/v2ray@.service

@ -1,22 +0,0 @@
[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_ADMIN CAP_NET_BIND_SERVICE
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
NoNewPrivileges=true
ExecStart=/usr/bin/v2ray/v2ray -config /etc/v2ray/%i.json
Restart=on-failure
[Install]
WantedBy=multi-user.target
Loading…
Cancel
Save