1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-22 01:57:12 -05:00

add systemd related config

This commit is contained in:
v2ray 2016-01-12 23:35:45 +01:00
parent 04e7dc87a8
commit a6b662b173
3 changed files with 30 additions and 2 deletions

View File

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

View File

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

View File

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