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
|
#!/bin/sh
#
# fsp.postinst: post installation script.
# Checks to see if fsp has been configured before; if so, quietly
# exits. If not, enquires to see whether the administrator wishes
# to duplicate the FTP archive in an FSP archive; if so, adds fsp
# to /etc/inetd.conf
set -e
case "$1"
in
configure)
# continue below
;;
abort-upgrade|abort-remove|abort-deconfigure)
exit 0;
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 0
;;
esac
# Checks if /etc/fspd.conf has a bad log directory - if so, ask
# the user if s/he wants to correct it. (fspd is by default setup
# to run as user ftp; 2.71-3 logged to /var/log/fspd, instead of
# /var/log/fsp/fspd, hence could not write to the log file.
# Quality control? Don't know the meaning of the word. :-)
#
# I intend to make this check disappear around release 8 or 9 - if
# it ever gets that far :-)
if [ "`grep /var/log/fspd /etc/fspd.conf`" ]; then
cat << EOF
Your current fspd.conf appears to have an incorrect directory for
logging connections and transfers to. fspd is by default setup to
run as the user "ftp"; your logfile appears to be /var/log/fspd,
which is only writeable by root.
EOF
while true
do
echo -n "Do you want me to attempt to correct the entry? (y/n) [y] "
read input
if [ "$input" = "y" -o "$input" = "Y" -o ! "$input" ]; then
tmpno=$RANDOM
sed -e 's/var\/log\/fspd/var\/log\/fsp\/fspd/' /etc/fspd.conf \
> /tmp/$tmpno
rm /etc/fspd.conf
cp /tmp/$tmpno /etc/fspd.conf
rm /tmp/$tmpno
break
fi
if [ "$input" = "n" -o "$input" = "N" ]; then
echo "Ok, not modifying fspd.conf."
break
fi
done
echo "You should check your /etc/fspd.conf to ensure that its values"
echo "are correct, especially if you are running fspd."
fi
if [ "`grep postinst /etc/fspd.conf`" ]; then
# Checks if the default fspd entry from 2.71-3 is in; if so, quietly
# replace it with the proper one. Does the same for the 2.71-[45] entry,
# which didn't have tcpd logging turned on.
if [ "`grep 'fsp dgram udp wait ftp /usr/sbin/tcpd' /etc/inetd.conf`" -o \
"`grep 'fsp dgram udp wait ftp /usr/sbin/fsp' /etc/inetd.conf`" ]
then
enabled=`grep fsp /etc/inetd.conf | grep -v "^[ \t]*#"`
update-inetd --remove fsp
update-inetd \
--add "fsp\tdgram\tudp\twait\tftp\t/usr/sbin/tcpd\t/usr/sbin/in.fspd"
if [ ! "$enabled" ]; then
update-inetd --disable fsp
fi
fi
# Assume fsp has been setup, and quietly exit.
exit 0
fi
if [ "$1" = "configure" ]; then
cat << EOF
If you want, I can configure FSP so that the daemon runs on UDP port
21, as user "ftp", providing access to the files stored in /home/ftp.
Some manual configuration of the daemon, and customization of the FTP
directory, may be required for the daemon to function as desired.
Note that setting up fspd is _not_ required to access FSP archives.
You only need to do this if you want to set up your own FSP archive.
If in doubt, say "no" for now, and read the documentation.
EOF
while true
do
# Assume n, so that only those who know what they're doing will use
# this (ie, it needs a deliberate act to setup the daemon.)
echo -n "Do you want me to do this? (y/n) [n] "
read input
if [ "$input" = "y" -o "$input" = "Y" ]; then
setupfspd=1
break
elif [ "$input" = "n" -o "$input" = "N" -o ! "$input" ]; then
setupfspd=0
break
fi
echo "Please answer \`Y' or \`N'."
done
if [ $setupfspd = 1 ]; then
echo -n "Setting up fspd in /etc/inetd.conf ... "
mkdir -p /home/ftp /var/log/fsp /var/lib/fspd
chown root.staff /home/ftp
if ! grep -q '^ftp:' /etc/passwd
then adduser --system --quiet --home /home/ftp --ingroup staff ftp
fi
chown ftp.staff /var/log/fsp /var/lib/fspd
update-inetd \
--add "fsp\tdgram\tudp\twait\tftp\t/usr/sbin/tcpd\t/usr/sbin/in.fspd"
# Just in case - probably an exercise in excessive superfluous redundancy :-)
update-inetd --enable fsp
echo "Done."
echo
echo "Please read the FSP documentation and ensure that the daemon is"
echo "configured properly for your system."
echo
else
echo -n "Making sure that the fsp daemon is disabled ... "
update-inetd --disable fsp
echo "Done."
if [ -d /home/ftp ]
then chown root.staff /home/ftp
fi
fi
echo "# Don't delete this line: postinst uses it to determine if FSP has been setup.">>/etc/fspd.conf
fi
|