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
|
#!/bin/bash
DEBIAN_CONFIG=/etc/cucipop.conf
cucipop_configured=no
run_mode=as_daemons
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 [ -f $DEBIAN_CONFIG ]; then
. $DEBIAN_CONFIG
cucipop_configured=yes
fi
if [ "$cucipop_configured" = "no" ]; then
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
if [ "$REPLY" = "Y" -o "$REPLY" = "y" ]; then
run_mode=from_inetd
fi
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"
if [ "$run_mode" = "as_daemons" ]; then
update-inetd --pattern "cucipop" --comment-chars "#<standalone># " \
--disable "pop-3"
echo "Cucipop typically has one zombie process, incidentially. This is"
echo "not a bug, but a feature -- it's faster that way."
else
update-inetd --pattern "cucipop" --comment-chars "#<standalone># " \
--enable "pop-3"
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
echo run_mode=\"$run_mode\" > $DEBIAN_CONFIG
#DEBHELPER#
|