add listen-timeout to function as an accept timeout
[socat/sam.git] / daemon.sh
blob2a9167a76b0e11143f05fbe4f319a0ebbed28011
1 #! /bin/sh
2 # source: daemon.sh
3 # Copyright Gerhard Rieger 2001
4 # Published under the GNU General Public License V.2, see file COPYING
6 # This script assumes that you create group daemon1 and user daemon1 before.
7 # they need only the right to exist (no login etc.)
9 # Note: this pid file mechanism is not robust!
11 # You will adapt these variables
12 USER=daemon1
13 GROUP=daemon1
14 INIF=fwnonsec.domain.org
15 OUTIF=fwsec.domain.org
16 TARGET=w3.intra.domain.org
17 INPORT=80
18 DSTPORT=80
20 INOPTS="fork,setgid=$GROUP,setuid=$USER"
21 OUTOPTS=
22 PIDFILE=/var/run/socat-$INPORT.pid
23 OPTS="-d -d -lm" # notice to stderr, then to syslog
24 SOCAT=/usr/local/bin/socat
26 if [ "$1" = "start" -o -z "$1" ]; then
28 $SOCAT $OPTS tcp-l:$INPORT,bind=$INIF,$INOPTS tcp:$TARGET:$DSTPORT,bind=$OUTIF,$OUTOPTS </dev/null &
29 echo $! >$PIDFILE
31 elif [ "$1" = "stop" ]; then
33 /bin/kill $(/bin/cat $PIDFILE)