You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
903 B

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  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
  5. # This script assumes that you create group daemon1 and user daemon1 before.
  6. # they need only the right to exist (no login etc.)
  7. # Note: this pid file mechanism is not robust!
  8. # You will adapt these variables
  9. USER=daemon1
  10. GROUP=daemon1
  11. INIF=fwnonsec.domain.org
  12. OUTIF=fwsec.domain.org
  13. TARGET=w3.intra.domain.org
  14. INPORT=80
  15. DSTPORT=80
  16. #
  17. INOPTS="fork,setgid=$GROUP,setuid=$USER"
  18. OUTOPTS=
  19. PIDFILE=/var/run/socat-$INPORT.pid
  20. OPTS="-d -d -lm" # notice to stderr, then to syslog
  21. SOCAT=/usr/local/bin/socat
  22. if [ "$1" = "start" -o -z "$1" ]; then
  23. $SOCAT $OPTS tcp-l:$INPORT,bind=$INIF,$INOPTS tcp:$TARGET:$DSTPORT,bind=$OUTIF,$OUTOPTS </dev/null &
  24. echo $! >$PIDFILE
  25. elif [ "$1" = "stop" ]; then
  26. /bin/kill $(/bin/cat $PIDFILE)
  27. fi