add systemd related config

pull/69/head
v2ray 9 years ago
parent 04e7dc87a8
commit a6b662b173

@ -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

@ -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"

@ -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

Loading…
Cancel
Save