Version 1.8.0.0
[socat.git] / daemon.sh
blob422c556b35df84bf28def1da765e7568d8db05f6
1 #! /bin/sh
2 # source: daemon.sh
3 # Copyright Gerhard Rieger and contributors (see file CHANGES)
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)