/[gentoo-x86]/net-proxy/obfsproxy/files/obfsproxy.initd
Gentoo

Contents of /net-proxy/obfsproxy/files/obfsproxy.initd

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download)
Sat Jan 19 16:00:49 2013 UTC (19 months, 3 weeks ago) by blueness
Branch: MAIN
CVS Tags: HEAD
Add initd for stand alone daemon

(Portage version: 2.1.11.31/cvs/Linux x86_64, signed Manifest commit with key 0xF52D4BBA)

1 #!/sbin/runscript
2 # Copyright 1999-2013 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License v2
4 # $Header: $
5
6 PIDFILE="/var/run/obfsproxy.pid"
7 DAEMON="/usr/bin/obfsproxy"
8
9 depend() {
10 need net
11 }
12
13 checkconfig() {
14 [[ "x${PROTOCOL}" = "x" ]] \
15 && eerror "PROTOCOL not given" && return 1
16 [[ "x${MODE}" = "x" ]] \
17 && eerror "MODE not given" && return 1
18 if [ ${PROTOCOL} = "dummy" ] ; then
19 [[ "x${LISTEN}" = "x" ]] \
20 && eerror "No listen address was given" && return 1
21 [[ "x${MODE}" = "xserver" && "x${TARGET}" = "x" ]] \
22 && eerror "MODE=server but no target address was given" && return 1
23 [[ "x${MODE}" = "xsocks" && "x${TARGET}" != "x" ]] \
24 && eerror "MODE=sock but a target address was given" && return 1
25 CMDLINE="${LOGGING} ${PROTOCOL} ${MODE} ${LISTEN} ${TARGET}"
26 elif [ ${PROTOCOL} = "obfs2" ] ; then
27 [[ "x${MODE}" = "xsocks" && "x${DESTINATION}" != "x" ]] \
28 && eerror "MODE=sock but a destination address was given" && return 1
29 [[ "x${LISTEN}" = "x" ]] \
30 && eerror "LISTEN host:port was not given" && return 1
31 [[ "x${DESTINATION}" != "x" ]] \
32 && DESTINATION="--dest=${DESTINATION}"
33 [[ "x${SECRET}" != "x" ]] \
34 && SECRET="--shared-secret=${SECRET}"
35 CMDLINE="${LOGGING} ${PROTOCOL} ${DESTINATION} ${SECRET} ${MODE} ${LISTEN}"
36 else
37 eerror "Unknown protocol ${PROTOCOL}"
38 return 1
39 fi
40 return 0
41 }
42
43 start() {
44 checkconfig || return 1
45 ebegin "Starting obfsproxy server"
46 start-stop-daemon --start \
47 --background --make-pidfile --pidfile ${PIDFILE} \
48 --exec ${DAEMON} -- ${CMDLINE}
49 eend $?
50 }
51
52 stop() {
53 ebegin "Stopping obfsproxy server"
54 start-stop-daemon --stop \
55 --pidfile ${PIDFILE} \
56 --exec ${DAEMON}
57 eend $?
58 }

  ViewVC Help
Powered by ViewVC 1.1.20