diff options
author | V3n3RiX <venerix@redcorelinux.org> | 2017-10-09 18:53:29 +0100 |
---|---|---|
committer | V3n3RiX <venerix@redcorelinux.org> | 2017-10-09 18:53:29 +0100 |
commit | 4f2d7949f03e1c198bc888f2d05f421d35c57e21 (patch) | |
tree | ba5f07bf3f9d22d82e54a462313f5d244036c768 /net-proxy/shadowsocks-libev/files/shadowsocks.initd |
reinit the tree, so we can have metadata
Diffstat (limited to 'net-proxy/shadowsocks-libev/files/shadowsocks.initd')
-rw-r--r-- | net-proxy/shadowsocks-libev/files/shadowsocks.initd | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/net-proxy/shadowsocks-libev/files/shadowsocks.initd b/net-proxy/shadowsocks-libev/files/shadowsocks.initd new file mode 100644 index 000000000000..e980bb2636e8 --- /dev/null +++ b/net-proxy/shadowsocks-libev/files/shadowsocks.initd @@ -0,0 +1,61 @@ +#!/sbin/openrc-run +# Copyright 1999-2015 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +SS_CONFIG="/etc/shadowsocks-libev/shadowsocks.json" + +SS_PIDFILE="/run/shadowsocks.pid" + +depend() { + need net +} + +checkconfig() { + if [ ! -f ${SS_CONFIG} ]; then + ewarn "${SS_CONFIG} does not exist." + fi + + SS_SVCNAME="${RC_SVCNAME#*.}" + case ${SS_SVCNAME} in + client) + SS_COMMAND="/usr/bin/ss-local" + return 0 + ;; + server) + SS_COMMAND="/usr/bin/ss-server" + return 0 + ;; + redir) + SS_COMMAND="/usr/bin/ss-redir" + return 0 + ;; + tunnel) + SS_COMMAND="/usr/bin/ss-tunnel" + return 0 + ;; + *) + eerror "please choose to run as server or client mode" + eerror " server: rc-update add shadowsocks.server default" + eerror " client: rc-update add shadowsocks.client default" + eerror " client: rc-update add shadowsocks.redir default" + eerror " client: rc-update add shadowsocks.tunnel default" + return 1 + ;; + esac +} + +start() { + checkconfig || return 1 + + ebegin "Starting Shadowsocks: ${SS_SVCNAME} mode" + start-stop-daemon --start --exec ${SS_COMMAND} \ + -- -c ${SS_CONFIG} -f ${SS_PIDFILE} >/dev/null 2>&1 & + eend $? +} + +stop() { + ebegin "Stopping Shadowsocks" + start-stop-daemon --stop --pidfile ${SS_PIDFILE} + eend $? +} + |