summaryrefslogtreecommitdiff
blob: f9c4bd7922f0d7c1cd9cbcf4279d7f46994af2dd (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
36
37
38
39
#!/sbin/runscript
# $Header: /var/cvsroot/gentoo-x86/net-misc/portfwd/files/portfwd.init,v 1.3 2003/12/03 21:22:18 avenj Exp $

depend() {
	need net
}

checkconfig() {
	if [ ! -e /etc/portfwd.cfg ] ; then
		eerror "You need an /etc/portfwd.cfg file first"
		eerror "There are samples in the documentation directory"
		return 1
	fi
}

start() {
    checkconfig || return 1
    ebegin "Starting portfwd"
    start-stop-daemon --start --quiet --pidfile /var/run/portfwd.pid --exec /usr/sbin/portfwd -- ${PORTFWD_OPTS}

    _pid="`ps --no-heading -C 'portfwd' -o pid | head -n 1`"
    if [ -n "$_pid" ] ; then
        echo "${_pid/ /}" > /var/run/portfwd.pid
        eend 0
    else
        eend 1
    fi
}

stop() {
    ebegin "Stopping portfwd"
    start-stop-daemon --stop --quiet --pidfile /var/run/portfwd.pid

    if [ $? -eq 0 ]; then
        rm -f /var/run/portfwd.pid
    fi

    eend $?
}