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 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
|
#!/bin/sh -e
# Automatically configure the server used by Leafnode and the access
# controls in /etc/hosts.allow. Mostly written by Joey Hess
# <joeyh@master.debian.org> with some additional bugs by Mark Brown
# <broonie@tardis.ed.ac.uk>
# Originally written for the Debian Leafnode package
CONFIG=/etc/news/leafnode/config
SAMPLE=/usr/share/doc/leafnode/examples/config.example
FETCHNEWS=/usr/sbin/fetchnews
# Guess the name of the upstream server to use
if [ -e /etc/news/server ]; then
remoteserver=`cat /etc/news/server`
if [ "$remoteserver" = "`hostname`" -o "$remoteserver" = "`hostname -f`" ]; then
remoteserver=
fi
fi
echo -n "
Leafnode configuration
----------------------
To what server will leafnode connect to download news? [$remoteserver] "
read answer
if [ -z "$answer" ]; then
answer=$remoteserver;
fi
echo -n "Setting up leafnode to use $answer as the nntp server..."
# Keep as many settings we don't know about as possible
if [ -e $CONFIG ]; then
cp $CONFIG ${CONFIG}.new
cp $CONFIG ${CONFIG}.0
else
# Debhelper may decided to compress the sample file, so we
# handle either case.
if [ -f ${SAMPLE}.gz ] ; then
gunzip -c ${SAMPLE}.gz > ${CONFIG}.new
else
cp $SAMPLE ${CONFIG}.new
fi
fi
# Eeek! This is horrible.
sed -e "/server.*=/ c\\
server = $answer\\" \
< ${CONFIG}.new > ${CONFIG}
if ! grep "server.*=" ${CONFIG} > /dev/null ; then
echo server = $answer > ${CONFIG}.tmp
cat ${CONFIG}.tmp ${CONFIG}.new > ${CONFIG}
rm -f ${CONFIG}.tmp
fi
rm -f ${CONFIG}.new
echo "done."
if ! grep -q '#-- leafnode begin' /etc/hosts.deny 2>/dev/null; then
echo -n "
If you do not enable some access controls for leafnode, people everywhere
will be able to use your news server, for things like posting spam or
accessing huge binary newsgroups. People activly scan the net for open news
servers.
If you do enable access controls, this will prevent any computers except
localhost from accessing your news server. You can modify /etc/hosts.allow
later to broaden the access controls, if necessary.
Enable access controls? [Yn] "
answer=""
while [ ! "$answer" ]; do
read answer
case "$answer" in
[Yy]*)
answer=y
;;
[Nn]*)
answer=n
;;
'')
answer=y
;;
*)
echo -n "Enable access controls? [Yn] "
answer=""
;;
esac
done
if [ "$answer" = "y" ]; then
echo -n "Setting up access controls in /etc/hosts.deny..."
echo "#-- leafnode begin" >> /etc/hosts.deny
echo "leafnode: ALL" >> /etc/hosts.deny
echo "#-- leafnode end" >> /etc/hosts.deny
echo "#-- leafnode begin" >> /etc/hosts.allow
echo "leafnode: 127.0.0.1" >> /etc/hosts.allow
echo "#-- leafnode end" >> /etc/hosts.allow
echo "done."
else
echo "You can enable access controls by hand at any time by editing"
echo "/etc/hosts.deny and /etc/hosts.allow."
echo "#-- leafnode begin" >> /etc/hosts.deny
echo "#leafnode: ALL" >> /etc/hosts.deny
echo "#-- leafnode end" >> /etc/hosts.deny
echo "#-- leafnode begin" >> /etc/hosts.allow
echo "#leafnode: 127.0.0.1" >> /etc/hosts.allow
echo "#-- leafnode end" >> /etc/hosts.allow
fi
fi
cat <<EOF
The default scripts provided with the package now support an
intermittent PPP connection. If you set up for a PPP connection then
fetchnews will be started whenever a PPP link is brought up and any
running fetchnews processes will be killed when the link is dropped.
Otherwise, news will be fetched daily as before. Either setting will
work with a PPP connection managed by diald.
EOF
echo -n "Set up for PPP connection? [Yn] "
answer=""
while [ ! "$answer" ]; do
read answer
case "$answer" in
[Yy]*)
answer=y
;;
[Nn]*)
answer=n
;;
'')
answer=y
;;
*)
echo -n "Set up for PPP connection? [yN] "
answer=""
;;
esac
done
if [ "$answer" = "n" ]; then
echo "Disabling PPP support..."
sed "/NETWORK=/ c\\
NETWORK=permanent\\" < /etc/news/leafnode/debian-config > /etc/news/leafnode/debian-config.new
mv /etc/news/leafnode/debian-config.new /etc/news/leafnode/debian-config
else
echo "Enabling PPP support..."
sed "/NETWORK=/ c\\
NETWORK=PPP\\" < /etc/news/leafnode/debian-config > /etc/news/leafnode/debian-config.new
mv /etc/news/leafnode/debian-config.new /etc/news/leafnode/debian-config
fi
echo -n "
Do you wish to update the list of availible groups now? [yN] "
answer=""
while [ ! $answer ]; do
read answer
case "$answer" in
[Yy]*)
answer=y
;;
[Nn]*)
answer=n
;;
'')
answer=n
;;
*)
echo -n "Do you wish to update the list of avalible groups now? [yN]"
answer=""
;;
esac
done
if [ "$answer" = "y" ]; then
$FETCHNEWS -f
fi
|