aboutsummaryrefslogtreecommitdiffstats
path: root/community/redsocks/redsocks.initd
blob: 592f19385ce32d2498e21fdd52802557789644a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/sbin/openrc-run

description="Transparent socks redirector"

CFGFILE="/etc/redsocks/${SVCNAME}.conf"
PIDFILE="/var/run/${SVCNAME}.pid"

depend() {
        need localmount net
        use dns logger
        after bootmisc firewall
}

checkconfig() {
	/usr/bin/redsocks -t -c ${CFGFILE}
        if [ "$?" -gt 0 ]; then
                eerror "Problem on configuration file ${CFGFILE}"
                return 1
        fi
}

start() {
        checkconfig || return 1
        ebegin "Starting ${SVCNAME}"
        start-stop-daemon --start --exec /usr/bin/redsocks --pidfile "${PIDFILE}" \
                -- -c "${CFGFILE}" -p "${PIDFILE}"
        eend $?
}

stop() {
        checkconfig || return 1
        ebegin "Stopping ${SVCNAME}"
        start-stop-daemon --stop --exec /usr/bin/redsocks --pidfile "${PIDFILE}"
        eend $?
}