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
|
#!/bin/bash
set -e
if ! chown root.mail /usr/sbin/cucipop
then
echo -e "ERROR: Please make sure the \"mail\" group exists.\n"
exit 1
fi
if [ "$(ls -ld /var/spool/mail | cut -b 25-28)" != "mail" ]
then
echo -n "Group of /var/spool/mail not \"mail\" -- fixing ... "
if chgrp mail /var/spool/mail
then
echo "ok."
else
exit 1
fi
fi
if [ "$(ls -ld /var/spool/mail | cut -b 5-7)" != "rws" ] \
&& [ "$(ls -ld /var/spool/mail | cut -b 5-7)" != "rwx" ]
then
echo -n "Group \"mail\" cannot write to /var/spool/mail -- fixing ... "
if chmod g+rwX /var/spool/mail
then
echo "ok."
else
exit 1
fi
fi
if [ "$1" != "upgrade" ]
then
echo -e "Updating /etc/inetd.conf to disable old pop-3 daemon and add cucipop.\n"
fi
update-inetd --remove "^.*removed.*pop-3.*/usr/sbin/cucipop"
update-inetd --remove "^pop-3.*/usr/sbin/cucipop"
update-inetd --comment-chars "#<cucipop># " --disable "pop-3"
update-inetd --group MAIL --comment-chars "#<standalone># " \
--add "pop-3 stream tcp nowait root /usr/sbin/tcpd /usr/sbin/cucipop -Ya"
update-inetd --pattern "cucipop" --comment-chars "#<standalone># " \
--disable "pop-3"
echo -e "Though cucipop normally runs as a standalone daemon (for speed), it"
echo "can also be run from inetd. This may be desirable in some cases, for"
echo -e "security or for preserving system resources.\n"
echo -n "Run cucipop from inetd (instead of usual standalone mode)? [N/y] "
if ! read
then
echo " (NO)"
fi
echo
if [ "$REPLY" = "Y" -o "$REPLY" = "y" ]
then
echo -n "Editing /etc/inetd.conf to enable cucipop..."
update-inetd --pattern "cucipop" --comment-chars "#<standalone># " \
--enable "pop-3"
echo -ne "done.\nEditing /etc/init.d/cucipop to prevent daemon mode ... "
sed s/run_cucipop=1/run_cucipop=0/ /etc/init.d/cucipop \
> /etc/init.d/cucipop.new.$$
mv /etc/init.d/cucipop.new.$$ /etc/init.d/cucipop
chmod 755 /etc/init.d/cucipop
chown root.root /etc/init.d/cucipop
echo -e "done.\n"
echo -ne "To run cucipop standalone, comment-out its line in inetd.conf, "
echo -e "then\nchange \"run_cucipop\" from 0 to 1 in /etc/init.d/cucipop."
else
echo -n "Editing /etc/init.d/cucipop to enable automatic start ... "
sed s/run_cucipop=0/run_cucipop=1/ /etc/init.d/cucipop > /etc/cuci.new.$$
mv /etc/cuci.new.$$ /etc/init.d/cucipop
chmod 755 /etc/init.d/cucipop
chown root.root /etc/init.d/cucipop
echo "done."
echo "To run cucipop from inetd, comment back in its line in inetd.conf,"
echo "then change \"run_cucipop\" from 1 to 0 in /etc/init.d/cucipop."
echo "Cucipop typically has one zombie process, incidentially. This is"
echo "not a bug, but a feature -- it's faster that way."
fi
echo -e "\nHere is the final state of the pop-3 service in inetd.conf:\n"
echo -e "$(grep pop-3 /etc/inetd.conf)\n"
chgrp -R mail /var/lib/cucipop 2> /dev/null || true
#DEBHELPER#
|