- 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>
149 lines
3.7 KiB
Bash
Executable File
149 lines
3.7 KiB
Bash
Executable File
#!/bin/sh
|
|
#
|
|
# Daily maintenance for Archie 3.5 — run as the archie user (e.g. via cron or
|
|
# the archie-arcontrol.timer systemd unit).
|
|
#
|
|
prog=$0
|
|
MAIL=${MAIL:-mail}
|
|
PATH=/bin:/usr/bin:/usr/local/bin
|
|
export PATH
|
|
|
|
usage()
|
|
{
|
|
cat - <<EOC
|
|
Usage: $0 [-h] [-c email-addr] [-v]
|
|
-h this message
|
|
-c email-addr send a copy of the statistics report here
|
|
-v verbose output
|
|
EOC
|
|
exit 1
|
|
}
|
|
|
|
fatal()
|
|
{
|
|
echo ""
|
|
echo "${prog}: $1"
|
|
exit 1
|
|
}
|
|
|
|
debug()
|
|
{
|
|
if [ x$verbose = xy ] ; then
|
|
echo "$1"
|
|
fi
|
|
}
|
|
|
|
get_home()
|
|
{
|
|
if [ $# -ne 1 ] ; then
|
|
fatal "get_home: bad number of arguments"
|
|
fi
|
|
# getent works with /etc/passwd, LDAP, SSSD — no NIS/ypmatch needed
|
|
if p=$(getent passwd "$1") ; then
|
|
echo "$p" | awk -F: '{print $6}'
|
|
else
|
|
fatal "get_home: can't find home directory for $1"
|
|
fi
|
|
}
|
|
|
|
restart_dirsrv()
|
|
{
|
|
if command -v systemctl >/dev/null 2>&1 ; then
|
|
debug "systemctl kill --signal=USR2 archie-dirsrv"
|
|
systemctl kill --signal=USR2 archie-dirsrv.service || true
|
|
else
|
|
pid=$(ps aux | grep '[d]irsrv' | awk '{print $2}' | head -1)
|
|
if [ -n "$pid" ] ; then
|
|
debug "kill -USR2 $pid"
|
|
kill -USR2 "$pid" || true
|
|
fi
|
|
fi
|
|
}
|
|
|
|
abort()
|
|
{
|
|
echo "Problem with $0. Aborting"
|
|
exit 2
|
|
}
|
|
|
|
# Default stats destination — override with -c
|
|
dest=""
|
|
|
|
MAILRC=/dev/null
|
|
export MAILRC
|
|
|
|
v=""
|
|
while [ $# -gt 0 ] ; do
|
|
case $1 in
|
|
-c) if [ $# -gt 1 ] ; then
|
|
shift
|
|
dest="${dest:+$dest,}$1"
|
|
else
|
|
echo "E-mail address required for -c"
|
|
usage
|
|
fi ;;
|
|
-x) set -x ;;
|
|
-v) verbose="y" ; v="-v" ;;
|
|
-h) usage ;;
|
|
*) echo "Unknown option [$1]" ; usage ;;
|
|
esac
|
|
shift
|
|
done
|
|
|
|
# gzip is always present on modern Linux; keep the check for safety
|
|
if gzip </dev/null >/dev/null 2>&1 ; then
|
|
gzip="y"
|
|
else
|
|
gzip="n"
|
|
echo "Note: gzip not found — log archives will not be compressed."
|
|
fi
|
|
|
|
home=$(get_home archie)
|
|
pfslog="$home/pfs/pfs.log"
|
|
pfshistory="$home/pfs/history"
|
|
|
|
# ── rotate archie logs ───────────────────────────────────────────────────────
|
|
debug "Cleaning up archie log files in $home/logs"
|
|
cd "$home/logs" || fatal "can't cd to $home/logs"
|
|
[ -d history ] || mkdir history || abort
|
|
|
|
for l in *.log ; do
|
|
[ -f "$l" ] || continue
|
|
"$home/bin/rotate" $v -d "$home/logs/history" -c "$l" 32
|
|
chown archie "$l"
|
|
done
|
|
|
|
# ── rotate Prospero log ──────────────────────────────────────────────────────
|
|
debug "Rotating Prospero log"
|
|
cd "$home/pfs" || fatal "can't cd to $home/pfs"
|
|
[ -d history ] || mkdir history || abort
|
|
|
|
"$home/bin/rotate" $v "$pfslog"
|
|
chown archie "$pfslog"
|
|
restart_dirsrv
|
|
|
|
# ── statistics report ────────────────────────────────────────────────────────
|
|
if [ -n "$dest" ] ; then
|
|
debug "Generating Prospero statistics"
|
|
cat "$pfshistory"/pfs.log.* 2>/dev/null | \
|
|
"$home/bin/prospero-stats.pl" | \
|
|
$MAIL -s "Archie Prospero Statistics" "$dest"
|
|
fi
|
|
|
|
# ── archive and trim old Prospero logs ──────────────────────────────────────
|
|
debug "Archiving Prospero log"
|
|
if cat "$pfshistory"/pfs.log.* 2>/dev/null | \
|
|
"$home/bin/trimplog.pl" $v -d "$pfshistory" -g "$gzip" ; then
|
|
debug "Trimming archived Prospero log"
|
|
rm -f "$pfshistory"/pfs.log.*
|
|
fi
|
|
|
|
cd "$pfshistory" || fatal "can't cd to $pfshistory"
|
|
debug "Removing history files older than 180 days"
|
|
find . -mtime +180 -print | xargs rm -f --
|
|
|
|
if [ "$gzip" = "n" ] ; then
|
|
debug "Compressing log files older than 7 days"
|
|
find . -mtime +7 -name '*.log*' -print | xargs gzip -f --
|
|
fi
|