diff options
Diffstat (limited to 'community/v2ray/v2ray.initd')
-rw-r--r-- | community/v2ray/v2ray.initd | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/community/v2ray/v2ray.initd b/community/v2ray/v2ray.initd new file mode 100644 index 00000000000..fe2e0f7c4de --- /dev/null +++ b/community/v2ray/v2ray.initd @@ -0,0 +1,38 @@ +#!/sbin/openrc-run +# Copyright 1999-2018 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +: ${V2_CONFIG:="/etc/v2ray/config.json"} +: ${V2_PIDFILE:="/run/v2ray.pid"} +: ${V2_LOG:="/var/log/v2ray.log"} + +extra_commands="checkconfig" + +depend() { + need net +} + +checkconfig() { + if [ ! -f ${V2_CONFIG} ]; then + ewarn "${V2_CONFIG} does not exist." + fi + v2ray test -c "$V2_CONFIG" +} + +start() { + checkconfig || return 1 + + ebegin "Starting V2ray" + ebegin "Log File : ${V2_LOG}" + start-stop-daemon --start \ + -b -1 ${V2_LOG} -2 ${V2_LOG} \ + -m -p ${V2_PIDFILE} \ + --exec /usr/bin/v2ray -- run -config ${V2_CONFIG} + eend $? +} + +stop() { + ebegin "Stopping V2ray" + start-stop-daemon --stop -p ${V2_PIDFILE} + eend $? +} |