Browse Source

add systemd related config

v2ray 9 năm trước cách đây
mục cha
commit
a6b662b173
3 tập tin đã thay đổi với 30 bổ sung2 xóa
  1. 13 0
      release/config/systemd/v2ray.service
  2. 8 2
      release/install-release.sh
  3. 9 0
      tools/build/config.go

+ 13 - 0
release/config/systemd/v2ray.service

@@ -0,0 +1,13 @@
+[Unit]
+Description=V2Ray Service
+After=network.target
+Wants=network.target
+
+[Service]
+Type=forking
+PIDFile=/var/run/v2ray.pid
+ExecStart=start-stop-daemon --start --quiet --pidfile /var/run/v2ray.pid --exec /usr/bin/v2ray/v2ray --background -m -- -config /etc/v2ray/config.json
+ExecStop=start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile /var/run/v2ray.pid
+
+[Install]
+WantedBy=multi-user.target

+ 8 - 2
release/install-release.sh

@@ -46,8 +46,14 @@ if [ ! -f "/etc/v2ray/config.json" ]; then
   echo "UUID:${UUID}"
 fi
 
-# Configure SysV if necessary.
-if [ -d "/etc/init.d" ]; then
+#if [ -d "/lib/systemd/system" ]; then
+#  if [ ! -f "/lib/systemd/system/v2ray.service" ]; then
+#    cp "/tmp/v2ray/v2ray-${VER}-linux-${VDIS}/systemd/v2ray.service" "/lib/systemd/system/"
+#    systemctl enable v2ray
+#  fi
+#el
+
+if [ -d "/etc/init.d" ]; then # Configure SysV if necessary.
   if [ ! -f "/etc/init.d/v2ray" ]; then
     cp "/tmp/v2ray/v2ray-${VER}-linux-${VDIS}/systemv/v2ray" "/etc/init.d/v2ray"
     chmod +x "/etc/init.d/v2ray"

+ 9 - 0
tools/build/config.go

@@ -55,6 +55,15 @@ func copyConfigFiles(dir string, goOS GoOS) error {
 		if err := copyConfigFile(src, dest, goOS, false); err != nil {
 			return err
 		}
+
+		if err := os.MkdirAll(filepath.Join(dir, "systemd"), os.ModeDir|0777); err != nil {
+			return err
+		}
+		src = filepath.Join(srcDir, "systemd", "v2ray.service")
+		dest = filepath.Join(dir, "systemd", "v2ray.service")
+		if err := copyConfigFile(src, dest, goOS, false); err != nil {
+			return err
+		}
 	}
 
 	return nil