New startup service file
parent
87e11835d6
commit
b1b6900629
|
@ -341,18 +341,20 @@ installV2Ray(){
|
||||||
|
|
||||||
# Used to store V2Ray log files
|
# Used to store V2Ray log files
|
||||||
if [[ ! -d '/var/log/v2ray/' ]]; then
|
if [[ ! -d '/var/log/v2ray/' ]]; then
|
||||||
install -d /var/log/v2ray/
|
install -d -o nobody -g nobody /var/log/v2ray/
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
installStartupServiceFile() {
|
installStartupServiceFile() {
|
||||||
if [[ ! -f '/etc/systemd/system/v2ray.service' ]]; then
|
if [[ ! -f '/etc/systemd/system/v2ray.service' ]]; then
|
||||||
mkdir "${TMP_DIRECTORY}systemd/system/"
|
mkdir "${TMP_DIRECTORY}systemd/system/"
|
||||||
curl ${PROXY} -o "${TMP_DIRECTORY}systemd/system/v2ray.service" https://raw.githubusercontent.workers.dev/v2fly/fhs-install-v2ray/master/systemd/system/v2ray.service -s
|
curl ${PROXY} -o "${TMP_DIRECTORY}systemd/system/v2ray.service" https://raw.githubusercontent.workers.dev/v2fly/fhs-install-v2ray/master/systemd/system/v2ray.service -s
|
||||||
|
curl ${PROXY} -o "${TMP_DIRECTORY}systemd/system/v2ray@.service" https://raw.githubusercontent.workers.dev/v2fly/fhs-install-v2ray/master/systemd/system/v2ray@.service -s
|
||||||
if [[ "$?" -ne '0' ]]; then
|
if [[ "$?" -ne '0' ]]; then
|
||||||
echo 'error: Failed to start service file download! Please check your network or try again.'
|
echo 'error: Failed to start service file download! Please check your network or try again.'
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
install -m 755 "${TMP_DIRECTORY}systemd/system/v2ray.service" /etc/systemd/system/v2ray.service
|
install -m 755 "${TMP_DIRECTORY}systemd/system/v2ray.service" /etc/systemd/system/v2ray.service
|
||||||
|
install -m 755 "${TMP_DIRECTORY}systemd/system/v2ray@.service" /etc/systemd/system/v2ray@.service
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,20 +1,14 @@
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=V2Ray Service
|
Description=V2Ray Service
|
||||||
After=network.target
|
After=network-online.target
|
||||||
Wants=network.target
|
Wants=network-online.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
# This service runs as root. You may consider to run it as another user for security concerns.
|
|
||||||
# By uncommenting the following two lines, this service will run as user v2ray/v2ray.
|
|
||||||
# More discussion at https://github.com/v2ray/v2ray-core/issues/1011
|
|
||||||
# User=v2ray
|
|
||||||
# Group=v2ray
|
|
||||||
Type=simple
|
Type=simple
|
||||||
PIDFile=/run/v2ray.pid
|
User=nobody
|
||||||
ExecStart=/usr/bin/env V2RAY_LOCATION_ASSET=/usr/local/lib/v2ray /usr/local/bin/v2ray -config /usr/local/etc/v2ray/config.json
|
AmbientCapabilities=CAP_NET_BIND_SERVICE
|
||||||
Restart=on-failure
|
Environment=V2RAY_LOCATION_ASSET=/usr/local/lib/v2ray/
|
||||||
# Don't restart in the case of configuration error
|
ExecStart=/usr/local/bin/v2ray -confdir /usr/local/etc/v2ray/
|
||||||
RestartPreventExitStatus=23
|
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
[Unit]
|
||||||
|
Description=V2Ray Service
|
||||||
|
After=network-online.target
|
||||||
|
Wants=network-online.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
User=nobody
|
||||||
|
AmbientCapabilities=CAP_NET_BIND_SERVICE
|
||||||
|
Environment=V2RAY_LOCATION_ASSET=/usr/local/lib/v2ray/
|
||||||
|
ExecStart=/usr/local/bin/v2ray -config /usr/local/etc/v2ray/%i.json
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
Loading…
Reference in New Issue