File: setup-daemontools.sh.in

package info (click to toggle)
leafnode 1.11.11-1
  • links: PTS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 2,468 kB
  • sloc: ansic: 10,914; sh: 1,748; xml: 628; makefile: 291; perl: 84; sed: 4
file content (149 lines) | stat: -rw-r--r-- 3,316 bytes parent folder | download | duplicates (8)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#! /bin/sh
# @configure_input@

set -e

confdir="@sysconfdir@"
sbindir="@sbindir@"
sname="leafnode-1"

unset LANG || :
unset LC_ALL || :
unset LC_MESSAGES || :

procs=""

debug() {
 :  printf >&2 "%s" "$1"
}

debugln() {
    debug "$1"
    debug "
"
}

yesno() {
    echo
    echo "$@"
    t='please enter yes or no: '
    ( printf "%s" "$t" ) || ( echo -n "$t" ) || echo "$t"
    read a
    case $a in
	[yY][eE][sS]) return 0 ;;
	[nN][oO]) return 1 ;;
	*) yesno "$@" ;;
    esac
}

daemontools() {
    set -e
    sdir=/service
    test -d $sdir || sdir=/var/service
    test -d $sdir || { echo "cannot find /service directory" ; exit 1; }

    (
    set -e
    umask 027
    cd "$confdir"
    for i in log env ; do 
	if test ! -d $i ; then 
	    mkdir $i
	    chmod 755 $i
	fi
    done
	cp -p run.tcpserver.dist run
	test -f Makefile || cp -p Makefile.dist Makefile
	test -f nntp.rules || cp -p nntp.rules.dist nntp.rules
	make -q nntp.cdb || make nntp.cdb
    chmod 755 run
    test -f env/MAXCONNECTIONS || echo '7

tcpserver will accept at most this many connections at the same time' \
	>env/MAXCONNECTIONS
    test -f env/LISTENIP || echo '127.0.0.1

What own IP leafnode should accept connections on.  This is the address
that your newsreaders must connect to.  Note that only clients on the
same interface as this address will be able to connect.

It must be a local address or 0.

Common are:     (explanation, do not type this in the first line!)
    127.0.0.1   (localhost)
    192.168.0.1 (for example in a LAN)
    0           (to allow connections to any local address)' >env/LISTENIP
    chown root:news env/MAXCONNECTIONS env/LISTENIP
    if test ! -f log/run ; then
	cat <<'_EOF' >log/run
#! /bin/sh
exec logger -p daemon.notice -t leafnode
_EOF
	chmod 755 log/run
    fi
    /command/svok ./. && /command/svc -t ./. || :
    )
    test $? -gt 0 && exit 1

    if test ! -d $sdir/$sname/. ; then
	ln -s "$confdir" $sdir/$sname
	echo "please stand by while svscan rescans its /service directory"
	sleep 6
    fi
    sleep 3
    echo
    echo 'The service should now be "up" for at least two seconds,'
    echo "otherwise, the setup failed. Should you be unable to connect to leafnode,"
    echo "please check the syslog for messages."
    /command/svstat $sdir/$sname/
    return 0
}

cat <<_EOF



*** leafnode setup.sh -- (C) 2002 by Matthias Andree ***

This program is intended to help you configure leafnode for
daemontools/tcpserver.

_EOF

debug "checking for user news... "
id -u news >/dev/null 2>&1 || {
    debugln "not found"
    echo >&2 "Please create a group news and a user news that is only in the news group"
    exit 1
}
debugln "found"

daemontools=0
test -x /command/svscanboot \
&& test -x /command/svscan \
&& test -x /command/envdir \
&& test -x /command/setuidgid \
&& daemontools=1

tcpserver=0
case @TCPSERVER@ in
    */tcpserver*) test -x @TCPSERVER@ && tcpserver=1 ;;
esac

bye=0
if test $daemontools = 0 ; then
    echo >&2 "daemontools is not installed, get it from http://cr.yp.to/daemontools.html"
    bye=1
fi

if test $tcpserver = 0 ; then
    echo >&2 "tcpserver is not installed, get it from http://cr.yp.to/ucspi-tcp.html"
    bye=1
fi

if test $bye = 1 ; then exit 1 ; fi

echo "setting up daemontools run leafnode from tcpserver"
daemontools

echo "finished."