File: daemon.sh

package info (click to toggle)
socat 1.7.3.2-2
  • links: PTS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 3,888 kB
  • sloc: ansic: 28,032; sh: 11,782; makefile: 146
file content (34 lines) | stat: -rwxr-xr-x 903 bytes parent folder | download
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
#! /bin/sh
# source: daemon.sh
# Copyright Gerhard Rieger and contributors (see file CHANGES)
# Published under the GNU General Public License V.2, see file COPYING

# This script assumes that you create group daemon1 and user daemon1 before.
# they need only the right to exist (no login etc.)

# Note: this pid file mechanism is not robust!

# You will adapt these variables
USER=daemon1
GROUP=daemon1
INIF=fwnonsec.domain.org
OUTIF=fwsec.domain.org
TARGET=w3.intra.domain.org
INPORT=80
DSTPORT=80
#
INOPTS="fork,setgid=$GROUP,setuid=$USER"
OUTOPTS=
PIDFILE=/var/run/socat-$INPORT.pid
OPTS="-d -d -lm"	# notice to stderr, then to syslog
SOCAT=/usr/local/bin/socat

if [ "$1" = "start" -o -z "$1" ]; then

    $SOCAT $OPTS tcp-l:$INPORT,bind=$INIF,$INOPTS tcp:$TARGET:$DSTPORT,bind=$OUTIF,$OUTOPTS </dev/null &
    echo $! >$PIDFILE

elif [ "$1" = "stop" ]; then

    /bin/kill $(/bin/cat $PIDFILE)
fi