Files
archie/scripts/mail_receiver
Mario Fetka 1e4baef047 Port Archie 3.5 to Linux/CMake, add Debian packaging and CI
- Replace autoconf/make build system with CMake (installs to /opt/archie)
- Add CPack DEB packaging for Debian Trixie (non-free/net, postinst creates
  archie user, extracts DB skeleton, sets setuid bits, enables systemd units)
- Add Gitea Actions workflow building .deb + binary/source tarballs on tag push
- Add portable archie_init.py for non-Debian post-install setup
- Port all scripts to Linux: getent passwd, systemctl, tail -n +N, gzip
- Add SFTP (libssh2) and FTPS (OpenSSL) scrapers alongside anonftp
- Add Flask web frontend (archie-web.service)
- Fix filter scripts (exec cat replaces broken sed s///g)
- Update all manpages: paths, contacts, add SFTP/FTPS section
- Update etc/: enable gzip, add webindex catalog, fix localhost refs
- Remove: AIX-2/SunOS-4.1.4/SunOS-5.4 dirs, tcl7.6/, tcl-dp/, tk4.2/,
  berkdb/, old Makefile.in/pre/post fragments, build.sh, unwrap scripts
- Add .gitignore

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-22 23:05:12 +02:00

108 lines
2.2 KiB
Bash
Executable File

#!/bin/sh -u
#
# We handle the output, from the telnet and e-mail clients, that is to
# be mailed to the user.
#
if [ $# -ge 1 ] ; then
if [ "$1" = "-d" ] ; then
set -x
fi
fi
do_trap ()
{
echo "${prog}: caught trap!" 1>&2
failure
}
failure ()
{
echo "${prog}: cleaning up and exiting." 1>&2
rm -f $info $mhead $data $part.*
exit 1
}
# ----------------- Configure ----------------------
#
# The path must include:
#
# - your mailer ($mailcmd) (e.g. /usr/lib/sendmail)
# - any compression programs ($compress) (e.g. compress)
# - any encoding programs ($encode) (e.g. /usr/bin/uuencode)
# - sed
# - cat
# - split_file (comes with archie)
# - echo
# - wc
# - expr
# - grep
# - rm
PATH=/usr/bin:/usr/lib:bin
#PATH=/usr/bin:/usr/lib:/archie/src/3.0/telnet-client/archie-client/mail_back_end
tmp=/tmp
# Must use quotes
mailcmd="sendmail -t -farchie-errors"
# --------------- End Configure --------------------
info=$tmp/Info$$
mhead=$tmp/Head$$
data=$tmp/Data$$
part=$tmp/Part$$
prog=`basename $0`
umask 077
trap do_trap 1 2 3 15
if sed -e "/@Begin/,/@MailHeader/w $info" -e "/@MailHeader/,/@End/w $mhead" \
-e '/@Begin/,/@End/d' > $data ; then
:
else
echo "${prog}: failed to extract info and mail headers." 1>&2
failure
fi
if acmd=`sed -n 's/Command: //p' < $info` && \
compress=`sed -n 's/Compress: //p' < $info` && \
encode=`sed -n 's/Encode: //p' < $info` && \
ms_size=`sed -n 's/MaxSplitSize: //p' < $info` ; then
:
else
echo "${prog}: failed to extract variables from info header." 1>&2
failure
fi
if [ "$compress" = "none" ] ; then
compress=cat
fi
# uuencode _requires_ an argument; pain in the butt
#
case $encode in
none) encode=cat ;;
uuencode) encode="uuencode archie-output" ;;
*) encode=cat ;;
esac
if $compress < $data | $encode | split_file -s $ms_size -f $part ; then
:
else
echo "${prog}: compress, encode, split_file pipeline failed." 1>&2
failure
fi
nparts=`echo $part.* | wc -w | sed 's/[ ][ ]*//g'`
for f in $part.* ; do
pnum=`expr $f : '.*\.\(.*\)$'`
(grep -v '^@' $mhead ; \
echo "Subject: archie [$acmd] part $pnum of $nparts" ; \
echo "" ; cat $f) | $mailcmd
done
rm -f $info $mhead $data $part.*
exit 0