add DESTDIR install to prospero

This commit is contained in:
Mario Fetka 2024-05-27 20:18:02 +02:00
parent 48c34d8fdb
commit 211e8efbc2
41 changed files with 2367 additions and 28 deletions

View File

@ -120,5 +120,6 @@ ln -sf Makefile.config.${SYSTYPE} Makefile.config
cp Makefile.in Makefile
make all_depend
make all
make install
cd ${WORLD_ROOT}

View File

@ -160,6 +160,8 @@ OPTIONAL_LIB_SUBDIRS = lib/psrv/wais_gw lib/psrv/gopher_gw
# These options are used only by 'make install' and 'make installbinaries'
# DISTDIR =
#### TOPDIR
# The top of the Prospero data files. You will only use this if you're
# running the Prospero server.

View File

@ -160,6 +160,8 @@ OPTIONAL_LIB_SUBDIRS =
# These options are used only by 'make install' and 'make installbinaries'
# DISTDIR =
#### TOPDIR
# The top of the Prospero data files. You will only use this if you're
# running the Prospero server.

View File

@ -161,6 +161,8 @@ COMPILER_PREPENDS_C_SYMBOLS_WITH_UNDERSCORE=_
# These options are used only by 'make install' and 'make installbinaries'
# DISTDIR =
#### TOPDIR
# The top of the Prospero data files. You will only use this if you're
# running the Prospero server.

View File

@ -161,6 +161,8 @@ OPTIONAL_LIB_SUBDIRS = lib/psrv/wais_gw lib/pcompat lib/psrv/gopher_gw
# These options are used only by 'make install' and 'make installbinaries'
# DISTDIR =
#### TOPDIR
# The top of the Prospero data files. You will only use this if you're
# running the Prospero server.

View File

@ -161,6 +161,8 @@ OPTIONAL_LIB_SUBDIRS = lib/psrv/wais_gw lib/psrv/gopher_gw
# These options are used only by 'make install' and 'make installbinaries'
# DESTDIR =
#### TOPDIR
# The top of the Prospero data files. You will only use this if you're
# running the Prospero server.

View File

@ -53,8 +53,8 @@ all: ${PROGS}
install:
-for i in ${PROGS} ; do \
X ${INSTALL} -c -m 755 -o ${OWNER} -g ${GROUP} $${i} ${P_BINARIES}/$${i}${GENERATIONSUFFIX} ;\
${GENERATION} ${P_BINARIES}/$${i} ;\
${INSTALL} -c -m 755 -o ${OWNER} -g ${GROUP} $${i} ${DISTDIR}/${P_BINARIES}/$${i}${GENERATIONSUFFIX} ;\
${GENERATION} ${DISTDIR}/${P_BINARIES}/$${i} ;\
done
# dependencies of all and OTHERPROGS

View File

@ -66,8 +66,8 @@ OBJECTS = ardp_abort.o \
all: ${RDP_LIB}
install:
cp ${RDP_LIB} ${P_BINARIES}/${RDP_LIB}
$(RANLIB) ${P_BINARIES}/${RDP_LIB}
cp ${RDP_LIB} ${DISTDIR}/${P_BINARIES}/${RDP_LIB}
$(RANLIB) ${DISTDIR}/${P_BINARIES}/${RDP_LIB}
${RDP_LIB}: ${OBJECTS}
rm -f ${RDP_LIB}

View File

@ -22,8 +22,8 @@ ${FIL_LIB}: ${OBJECTS}
install:
# cp ${FIL_LIB} ${P_BINARIES}/${FIL_LIB}
# $(RANLIB) ${P_BINARIES}/${FIL_LIB}
# cp ${FIL_LIB} ${DISTDIR}/${P_BINARIES}/${FIL_LIB}
# $(RANLIB) ${DISTDIR}/${P_BINARIES}/${FIL_LIB}
# Dependencies
nl_apply_fil.o : \

View File

@ -48,8 +48,8 @@ ${CMP_LIB}: ${OBJECTS}
install:
# $(INSTALL) -o $(OWNER) -g $(GROUP) ${CMP_LIB} ${P_BINARIES}/${CMP_LIB}
# ranlib ${P_BINARIES}/${CMP_LIB}
# $(INSTALL) -o $(OWNER) -g $(GROUP) ${CMP_LIB} ${DISTDIR}/${P_BINARIES}/${CMP_LIB}
# ranlib ${DISTDIR}/${P_BINARIES}/${CMP_LIB}
# Dependencies

View File

@ -238,8 +238,8 @@ SPECIAL_OTHERTARGETS = $(PFS_LIB)
install:
# We currently don't install this library
# cp ${PFS_LIB} ${P_BINARIES}/${PFS_LIB}
# $(RANLIB) ${P_BINARIES}/${PFS_LIB}
# cp ${PFS_LIB} ${DISTDIR}/${P_BINARIES}/${PFS_LIB}
# $(RANLIB) ${DISTDIR}/${P_BINARIES}/${PFS_LIB}
${PFS_LIB}: ${OBJECTS}
rm -f ${PFS_LIB}

View File

@ -57,8 +57,8 @@ all: ${SRV_LIB} all_subdirs
install:
# cp ${SRV_LIB} ${P_BINARIES}/${SRV_LIB}
# ${RANLIB} ${P_BINARIES}/${SRV_LIB}
# cp ${SRV_LIB} ${DISTDIR}/${P_BINARIES}/${SRV_LIB}
# ${RANLIB} ${DISTDIR}/${P_BINARIES}/${SRV_LIB}
${SRV_LIB}: ${OBJECTS}

View File

@ -86,8 +86,8 @@ ${WAIS_GW_LIB}: ${OBJS} ${UTIL} ${GW}
install: sourceparse ietftypes
-for i in sourceparse ietftypes ; do \
${INSTALL} -c -m 755 -o ${OWNER} -g ${GROUP} $$i ${P_BINARIES}/$$i${GENERATIONSUFFIX}; \
${GENERATION} ${P_BINARIES}/$$i ; \
${INSTALL} -c -m 755 -o ${OWNER} -g ${GROUP} $$i ${DISTDIR}/${P_BINARIES}/$$i${GENERATIONSUFFIX}; \
${GENERATION} ${DISTDIR}/${P_BINARIES}/$$i ; \
done

View File

@ -73,8 +73,8 @@ shadowcvt: shadowcvt.o cvt_v1_ltype.o $(SRV_LIBS_DEPENDENCIES)
install:
-for i in ${SPECIAL_PROGS} ${MORE_SERVER_PROGS}; do \
${INSTALL} -c -m 755 -o ${OWNER} -g ${GROUP} $$i ${P_BINARIES}/$$i${GENERATIONSUFFIX}; \
${GENERATION} ${P_BINARIES}/$$i ; \
${INSTALL} -c -m 755 -o ${OWNER} -g ${GROUP} $$i ${DISTDIR}/${P_BINARIES}/$$i${GENERATIONSUFFIX}; \
${GENERATION} ${DISTDIR}/${P_BINARIES}/$$i ; \
done
-chmod 6755 ${P_BINARIES}/pstart

View File

@ -76,16 +76,16 @@ all: $(PROGS) $(SPECIAL_PROGS) $(DATA_FILE_TARGETS) $(MORE_USER_PROGS) all_subdi
install:
-for i in $(PROGS) $(SPECIAL_PROGS) $(MORE_USER_PROGS); do \
$(INSTALL) -c -m 755 -o $(OWNER) -g $(GROUP) $$(i) $(P_BINARIES)/$$(i)$(GENERATIONSUFFIX) ;\
$(GENERATION) $(P_BINARIES)/$$(i) ;\
$(INSTALL) -c -m 755 -o $(OWNER) -g $(GROUP) $$(i) $(DISTDIR)/$(P_BINARIES)/$$(i)$(GENERATIONSUFFIX) ;\
$(GENERATION) $(DISTDIR)/$(P_BINARIES)/$$(i) ;\
done
-rm -f $(P_BINARIES)/pkl
-ln $(P_BINARIES)/padmin $(P_BINARIES)/pkl
-rm -f $(P_BINARIES)/ppw
-ln $(P_BINARIES)/psession $(P_BINARIES)/ppw
-rm -f $(DISTDIR)/$(P_BINARIES)/pkl
-ln padmin $(DISTDIR)/$(P_BINARIES)/pkl
-rm -f $(DISTDIR)/$(P_BINARIES)/ppw
-ln psession $(DISTDIR)/$(P_BINARIES)/ppw
-for i in $(DATA_FILE_TARGETS) ; do \
$(INSTALL) -m 644 -o $(OWNER) -g $(GROUP) $$(i) $(P_BINARIES)/$$(i)$(GENERATIONSUFFIX) ;\
$(GENERATION) $(P_BINARIES)/$$(i) ;\
$(INSTALL) -m 644 -o $(OWNER) -g $(GROUP) $$(i) $(DISTDIR)/$(P_BINARIES)/$$(i)$(GENERATIONSUFFIX) ;\
$(GENERATION) $(DISTDIR)/$(P_BINARIES)/$$(i) ;\
done
$(SUBDIRS_MAKE_START) install $(SUBDIRS_MAKE_END)

View File

@ -23,8 +23,8 @@ ${MENU_LIB}: ${OBJECTS}
$(RANLIB) ${MENU_LIB}
install:
-${INSTALL} -c -m $(INSTALL_EXE_MODE) -o ${OWNER} -g ${GROUP} menu ${P_BINARIES}/menu${GENERATIONSUFFIX}
-${GENERATION} ${P_BINARIES}/menu
-${INSTALL} -c -m $(INSTALL_EXE_MODE) -o ${OWNER} -g ${GROUP} menu ${DISTDIR}/${P_BINARIES}/menu${GENERATIONSUFFIX}
-${GENERATION} ${DISTDIR}/${P_BINARIES}/menu
# Dependencies

View File

@ -67,8 +67,8 @@ vcache: $(XLIBOBJECTS) $(PFS_VCACHE_LIBS_DEPENDENCIES)
install:
${INSTALL} -c -o ${OWNER} -g ${GROUP} -m $(INSTALL_EXE_MODE) vcache \
${P_BINARIES}/vcache${GENERATIONSUFFIX}
${GENERATION} ${P_BINARIES}/vcache
${DISTDIR}/${P_BINARIES}/vcache${GENERATIONSUFFIX}
${GENERATION} ${DISTDIR}/${P_BINARIES}/vcache
# This library is not generally installed.
# ${INSTALL} -c -o ${OWNER} -g ${GROUP} -m 644 ${VCACHE_LIB} \

116
release/scripts/archie.shell Executable file
View File

@ -0,0 +1,116 @@
#!/bin/sh
# This script written by Jim Martin, Rutgers University (jim@rutgers.edu)
#
# Modified by Alan Emtage, Bunyip Information Systems (bajan@bunyip.com)
# Modified by Luc Boulianne, Bunyip Information Systems (lucb@bunyip.com)
# Modified by Andreas Liebe for Solaris <liebe@hrz.th-darmstadt.de>
# Modified by Lee McLoughlin for Solaris 2.3 and for security <lmjm@doc.ic.ac.uk>
# DONT let the user interrupt me to try and get a shell
trap "kill -HUP 0" 1 2 3 15
#
# Set the maximum number of interactive sessions here
#
max=10
# define this to specify a file to print before going into telnet-client
# this is useful if dirsrv looses the MOTD.
motd=$HOME/etc/motd
# Set the nice level (priority) here. It must be >= 0
#
nicelevel=0
# define this if you want to warn the user about reaching the wrong
# host. You will also need to update the message below.
host=`uname -n`
prog=$0
fatal()
{
echo ""
echo "${prog}: $1"
exit 1
}
get_home()
{
if [ $# -ne 1 ] ; then
fatal "get_home: bad number of arguments"
fi
if p=`grep "^${1}:" /etc/passwd` ; then
echo $p | awk -F: '{print $6}'
elif p=`ypmatch $1 passwd` ; then
echo $p | awk -F: '{print $6}'
else
fatal "get_home: can't find home directory for $1"
fi
}
HOME=`get_home ${LOGNAME:-\`whoami\`}`
#stty new crt erase "^?" kill "^u" echo intr "^c"
#stty crt erase "^?" kill "^u" echo intr "^c"
stty erase "^?" kill "^u" echo intr "^c"
case "$fixing" in
'') ;;
*)
echo "working on archie - please try again later or try one of:"
cat $HOME/etc/serverlist
echo The current time is `date`
sleep 5
exit 0
esac
# # Tailor this if required.
# case "$host" in
# '') ;;
# phoenix.*)
# ;;
# *)
# echo "You must be running old nameserver software"
# echo "archie.doc.ic.ac.uk should now get you to:"
# echo " phoenix.doc.ic.ac.uk [146.169.2.10]"
# echo "please check with your local administrators about this"
# sleep 6
# exit 0
# ;;
# esac
if [ `uname -s` = AIX ] ; then
sofar=`/bin/ps agux | grep telnet-client | grep -v grep | wc -l`
else
sofar=`who | grep archie | grep -v grep | wc -l`
fi
#
# The message that you want displayed should be set here after the
# ALL ARCHIE SESSIONS IN USE message and before the _end_
#
if [ $sofar -gt $max ]; then
cat <<_end_
ALL ARCHIE SESSIONS IN USE
I'm sorry. This archie server is currently at the limit of its
interactive login sessions. Please use another archie server or try again
later.
-archie administration
_end_
echo "So far $sofar > $max (max)"
cat $HOME/etc/serverlist
echo The current time is `date`
sleep 5
exit 0
fi
case "$motd" in
'') ;;
*)
if [ -r $motd ]; then
cat $motd
fi
;;
esac
exec nice -$nicelevel $HOME/bin/telnet-client -s

74
release/scripts/archiemail Executable file
View File

@ -0,0 +1,74 @@
#!/bin/sh
#
# Invoke the script that mails output back to the user.
# If any errors are generated by this script, collect them
# and mail them to `recipient'.
#
# Modified by Lee McLoughlin for Solaris 2.3 <lmjm@doc.ic.ac.uk>
#
# The path must include:
#
# - the `mail_receiver' shell script
# - a mail program that takes the -s option
# - rm
# - whoami
PATH=/usr/ucb:/bin:bin
#PATH=/usr/ucb:/bin:/archie/src/3.0/telnet-client/archie-client/mail_back_end
# ---------------- Configure ----------------
# the address, at your site, to which to mail errors generated
# when attepmting to send mail
recipient=archie-errors
#
# temporary file in which to collect any error messages
err=/tmp/mailerr$$
# -------------- End Configure --------------
> $err
# lmjm:
exec 2> $err
if [ $# -ge 1 ] ; then
if [ "$1" != "-d" ] ; then
args=""
else
exec 2> $err
set -x
args="-d"
fi
fi
fatal()
{
echo ""
echo "${prog}: $1"
exit 1
}
get_home()
{
if [ $# -ne 1 ] ; then
fatal "get_home: bad number of arguments"
fi
if p=`grep "^${1}:" /etc/passwd` ; then
echo $p | awk -F: '{print $6}'
elif p=`ypmatch $1 passwd` ; then
echo $p | awk -F: '{print $6}'
else
fatal "get_home: can't find home directory for $1"
fi
}
prog=`basename $0`
if cd `get_home \`whoami\`` ; then
:
else
fatal "can't change to home directory!"
fi
umask 077
bin/mail_receiver $args 2>> $err
if [ -f $err -a -s $err ] ; then
mail -s "error from mail_receiver $err" $recipient < $err
fi
rm -f $err

12
release/scripts/aslip Executable file
View File

@ -0,0 +1,12 @@
#!/bin/csh
set DBIN=~archie/bin
set T=telnet-client
set tc=$DBIN/$T
set otc=$DBIN/$T-
set ntc=$DBIN/$T+
if ( -f $T ) then
cp $tc $ntc && cp $T $ntc && rm -f $otc && ln $tc $otc && mv $ntc $tc
else
echo "Error: $T not in current directory"
endif

46
release/scripts/batch-email Executable file
View File

@ -0,0 +1,46 @@
#!/bin/sh
#
# batch-email (c) Copyright Bunyip Information Systems, Inc. 1994
#
# This routine can be used to batch incoming email requests for later
# processing
#
PATH=/bin:/usr/bin:/usr/ucb
if p=`grep "^archie:" /etc/passwd` ; then
archiehome=`echo $p | awk -F: '{print $6}'`
elif p=`ypmatch archie passwd` ; then
archiehome=`echo $p | awk -F: '{print $6}'`
fi
ch_tmp()
{
cd $archiehome/db/tmp
}
usage() {
echo "Usage: batch-email -t <tmp dir>"
exit 1
}
tdir="notset"
while [ $# -gt 1 ] ; do
case $1 in
#temp directory
-t) if [ $# -gt 1 ] ; then shift ; tdir=$1; else usage; fi;;
esac
shift
done
if [ $tdir = "notset" ]; then
ch_tmp
else
cd $tdir
fi
cat > aremail.`date +%y.%T`.$$

202
release/scripts/daily.admin Executable file
View File

@ -0,0 +1,202 @@
#!/bin/sh
#
# This adminstration file contains commands that archuser should run once a
# day. A good time is somewhere around midnight, local time
#
# 1995 (c) Bunyip Information Systems Inc.
# written by Luc Boulianne <lucb@bunyip.com>
#
# $Id: daily.admin,v 1.4 1995/03/14 21:20:57 pedro Exp $
#
prog=$0
MAIL=/usr/ucb/Mail
PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin
export PATH
usage()
{
cat - <<EOC
Usage: $0 [-h] [-c email-addr] [-v]
-h this message
-c email-addr Email address to send a copy of the statistics report
-v verbose messages
EOC
exit 1
}
restart_dirsrv ()
{
pid=`$PS | grep dirsrv | grep -v grep | awk '{print $2}'`
debug "kill -USR2 $pid"
if kill -USR2 $pid ; then
debug "dirsrv signaled to re-open log file"
else
echo "*WARNING* dirsrv running as root; signal ignored"
fi
}
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
if p=`grep "^${1}:" /etc/passwd` ; then
echo $p | awk -F: '{print $6}'
elif p=`ypmatch $1 passwd` ; then
echo $p | awk -F: '{print $6}'
else
fatal "get_home: can't find home directory for $1"
fi
}
abort () {
echo "Problem with $0. Aborting";
exit -2;
}
# Please do not change is address.
# Use the -c flag to append additional addresses
dest="prospero-stats@archie.bunyip.com";
# Disable the users .mailrc file
MAILRC=/dev/null
export MAILRC
v="";
while [ $# -gt 0 ] ; do
case $1 in
-c) if [ $# -gt 1 ] ; then
shift;
dest="$dest,$1";
else
echo "E-mail address required for this flag"
usage;
fi ;;
-x) set -x;;
-v) verbose="y";
v="-v";;
-h) usage;;
*) echo "Unknown option [$1]";
usage;;
esac
shift
done
if gzip </dev/null >> /dev/null ; then
gzip="y";
else
gzip="n";
cat - << EOC
Note: \`gzip' not found on this system. This script will run nonetheless,
however please install it if you can, as we are using some features of \`gzip'
not available to \`compress'. Bunyip can assist if you need help.
EOC
fi
osname=`uname`
rel=`uname -r | sed 's/\..*$//'`
case $osname in
"SunOS")
tlink="-h"
if [ x$rel = x4 ] ; then
PS="/bin/ps aguxwww"
else
PS="/usr/ucb/ps aguxwww"
fi
;;
"AIX")
tlink="-L"
PS="/bin/ps -aef"
;;
esac
home=`get_home archie`
odirsrv=`$PS | grep dirsrv | grep -v grep | awk '{print $1}'`
debug "dirsrv owned by $odirsrv"
if [ "$odirsrv" = "root" ] ; then
# A truly atrocious hack. Need to have a configuration script for
# this stuff - lucb
eval `grep '^ARCHIE_USER' ../bin/mail_stats`;
id=`id | sed 's/(.*$//' | sed 's/^.*=//'`;
debug "Your uid is $id";
if [ $id -ne 0 ]; then
echo "*PROBLEM* Dirsrv is running as root. $0 must also run as root"
echo "*PROBLEM* Dirsrv is running as root. $0 must also run as root"|\
$MAIL -s "Problem with $0" $ARCHIE_USER
exit 2;
fi
fi
debug "Cleaning up archie log files in $home/logs"
cd $home/logs
if [ ! \( -d history -o $tlink history \) ] ; then
mkdir history || abort
fi
# Keep 32 days of archie and email logs
f=`ls *.log`;
for l in $f; do
$home/scripts/rotate $v -d $home/logs/history -c $l 32;
chown archie $l;
chgrp archie $l;
done
debug "Taking care of the prospero logs"
cd $home/pfs
if [ ! \( -d history -o $tlink history \) ] ; then
mkdir history || abort
fi
$home/scripts/rotate $v pfs.log
chown archie pfs.log
restart_dirsrv
# $home/scripts/eval-perf.pl < /pfs/pfs.log
debug "Generating prospero statistics"
cat /pfs/pfs.log.* | $home/scripts/prospero-stats.pl | \
$MAIL -s "Prospero Statistics Report" $dest
debug "Archiving prospero log"
if cat /pfs/pfs.log.* | $home/scripts/trimplog.pl $v -d /pfs/history -g $gzip ; then
debug "Trimming prospero log"
rm -f /pfs/pfs.log.*
fi
cd /pfs/history
debug "Clean history files older than six months"
find . -mtime +180 -print | xargs rm
# If gzip is not available, then compress the log files after 7
# days. DO NOT COMPRESS immediately. trimplog may append to an already
# existing log file. If gzip is available, compression will be automatic,
# as gzip allows concatenation of compressed items.
if [ $gzip = "n" ] ; then
debug "Compressing archived log files older than seven days"
find . -mtime +7 -print | xargs compress
fi

74
release/scripts/eval-perf.pl Executable file
View File

@ -0,0 +1,74 @@
#!/usr/local/bin/perl
#
# evaluate the ~archie/pfs/pfs.log file (from standard input).
#
# written by Thomas Lenggenhager, SWICH <lenggenhager@switch.ch>
# 940731
#
open(OUT, ">performance");
while (<>) {
if (/^(..-...-..) (..):(..):(..) .* - L ARCHIE\/MATCH\((\d*).*(.)\)(.*)/) {
$date = $1; $hour = $2; $min = $3; $sec = $4;
$max = $5; $type = $6; $string = $7;
$search = 1;
} elsif (/^(..-...-..) (..):(..):(..) .* - matches: (\d*)/) {
next unless $search;
$search = 0;
$match = $5;
if ($hour > $2) {
$secs = 60 - $sec;
$secs += (60 - $min - 1) * 60;
$secs += (($2 * 60) + $3) * 60 + $4;
} elsif ($min > $3) {
$secs = 60 - $sec;
$secs += (60 - $min -1) * 60;
$secs += (((($2 - $hour - 1) * 60) + $3) * 60) + $4;
} elsif ($sec > $4) {
$secs = 60 - $sec;
$secs += ($3 - $min - 1) * 60 + $4;
} else {
$secs = $4 - $sec;
}
print OUT "$hour:$min:$sec - $2:$3:$4\t$secs\t$type $max\t$match\t$string\n";
$count++;
$sum += $secs;
$sqsum += $secs * $secs;
$count{$type}++;
$sum{$type} += $secs;
$sqsum{$type} += $secs * $secs;
if ($secs > $maxsecs) {
$maxsecs = $secs;
}
if ($secs > $maxsecs{$type}) {
$maxsecs{$type} = $secs;
}
if ($secs > 120) {
print OUT "$hour:$min:$sec - $2:$3:$4\t$secs\t$type $max\t$match\t$string\n";
}
# last if $count == 500;
}
}
print OUT "\nResults for all Queries:\n";
if ($count < 2) {
print OUT "No data in log file\n";
exit
}
$medium = $sum/$count;
$variance = ($sqsum - $medium)/($count - 1);
printf OUT "Samples:\t%d\n", $count;
printf OUT "Mean:\t\t%f\n", $medium;
printf OUT "Std.-deviation:\t%f\n", sqrt($variance);
printf OUT "Maximum:\t%d\n", $maxsecs;
print OUT "\n";
foreach $type (sort keys %count) {
next if ($count{$type} < 2);
print OUT "Results for <$type> Queries:\n";
$medium = $sum{$type}/$count{$type};
$variance = ($sqsum{$type} - $medium)/($count{$type} - 1);
printf OUT "Samples:\t%d\n", $count{$type};
printf OUT "Mean:\t\t%f\n", $medium;
printf OUT "Std.-deviation:\t%f\n", sqrt($variance);
printf OUT "Maximum:\t%d\n", $maxsecs{$type};
print OUT "\n";
}

View File

@ -0,0 +1,3 @@
#!/bin/sh
sed s/ //g

View File

@ -0,0 +1,152 @@
#!/usr/local/bin/perl
#
# $Id: filter_anonftp_unix_bsd,v 1.1 1995/01/11 08:03:50 lucb Exp $
#
$non_crud = $perm_denied = $not_found = "";
while( <> ){
next_one:
# Stomp on carriage returns
s/\015//g;
# Try and spot crud in the line and avoid it
# You can get:
# -rw-r--r-ls: navn/internett/RCS/nsc,v: Permission denied
# ls: navn/internett/RCS/bih,v: Permission denied
# - 1 43 daemon 1350 Oct 28 14:03 sognhs
# -rwcannot access .stuff/incoming
# cannot access .stuff/.cshrc
# UX:ls * .. this was found in IRIX systems recently. The whole line
# should be ignored (Bibi Oct-5-95)
if( m%^(.*)/bin/ls:.*Permission denied% ||
m%^UX:ls:.*Permission denied% ||
m%^(.*)ls:.*Permission denied% ||
m%^(.*)(cannot|can not) access % ){
if( ! $non_crud ){
$non_crud = $1;
}
next;
}
# Also try and spot non ls "Permission denied" messages. These
# are a LOT harder to handle as the key part is at the end
# of the message. For now just zap any line containing it
# and the first line following (as it will PROBABLY have been broken).
#
if( /.:\s*Permission denied/ ){
$perm_denied = 1;
next;
}
if( /.:\s*No permission/ ) {
$perm_denied = 1;
next;
}
if( $perm_denied ){
$perm_denied = "";
# warn "Warning: input corrupted by \"Permission denied\" errors, about line $. of $lsparse'name\n";
next;
}
# Not found's are like Permission denied's. They can start part
# way through a line but with no way of spotting where they begin
if( /not found/ ){
$not_found = 1;
next;
}
if( $not_found ){
$not_found = "";
# warn "Warning: input corrupted by \"not found\" errors, about line $. of $lsparse'name\n";
next;
}
if( $non_crud ){
$_ = $non_crud . $_;
$non_crud = "";
}
# Bibi added this to take care of the AIX listings where the D/F replace the
# d/- in Sunos listings.
if(/^([DF][-rwxSsTt]{9}).*\s(\d+)\s*(\w\w\w\s+\d+\s*(\d+:\d+|\d\d\d\d))\s+(.*)$/ ){
s%^D%d%;
s%^F%-%;
}
# Fixes the year's trailing spaces for AIX listings.
if( /^([-dl][-rwxSsTt]{9}).*\s(\d+)\s*\w\w\w\s+\d+(\s(\d\d\d\d)\s\s)(.*)$/ ){
$subs = $4;
s%$3% $subs %;
}
# Bibi added this to take of filenames tht start with \n!! I ignore it and
# ignore the following lines if they are still part of this filename.
if(/^([-dl][-rwxSsTt]{9}).*\s(\d+)\s*(\w\w\w\s+\d+\s*(\d+:\d+|\d\d\d\d))\s(\n)$/ ){
while($_ = <>){
if(/^([-dl][-rwxSsTt]{9}).*\s(\d+)\s*(\w\w\w\s+\d+\s*(\d+:\d+|\d\d\d\d))\s+(.*)$/ ){
goto next_one;
}else{
if( /:(\s)*$/ ){
print "\n";
goto next_one;
}
next;
}
}
next;
}
if( (/^([-dl][-rwxSsTtl]{9}).*\s(\d+)\s*(\w\w\w\s+\d+\s*(\d+:\d+|\d\d\d\d))\s(\.|\.\.)$/ ) ||
/^total[ ][ ]*[0-9][0-9]*[ ]*$/ ||
/^ls:(\s*)total[ ][ ]*[0-9][0-9]*[ ]*$/ ||
/^Total:[ ][ ]*[0-9][0-9]*[ ]*kbytes$/ ||
/^opendir:.*$/ ||
/^\.:$/ ||
/^\.$/ ||
(/^.*[ ][ ]*unreadable?[ ]*$/ &&
!(/^([-dl][-rwxSsTtl]{9}).*/) )||
/^[cb][-rwxSsTt]\{9\}/ ||
/^ld.so: warning: / ||
/^crt0: no / ||
# These next 4 lines are to remove the crap at the start of the
# nikhefh.nikhef.nl listing
/This is:/ ||
/NIKHEF-H, National Institute/ ||
/Kruislaan 409, P.O. Box/ ||
/Questions to:/ ||
# Not sure about where this one comes from.
/WE ARE IN EUROPE/ ){
next;
}
s%^\./%%;
s%^/usr/spool/ftp/%%;
s%^/pub/%%;
s%^/usr/local/pub/%%;
s%^/home/ftp/pub/%%;
s%^/ftp/pub/%%;
s%^/com/ftp/pub/%%;
s%^/com/ftp/sun4/pub/%%;
s%^/var/spool/uucppublic/%%;
# -rw-r--r--+ from ghost.dsi.unimi.it (lucb)
s%^([-cbdlrwxSsTt]{10})\+%$1 %;
local( $dir_line );
s%^([-dl][-rwxSsTt]{9})([0-9]+)%$1 $2%;
if( /^([-dl][-rwxSsTt]{9}).*\s(\d+)\s*(\w\w\w\s+\d+\s*(\d+:\d+|\d\d\d\d))\s+(.*)$/ ){
$file_line = 1;
s,/$,,;
}
elsif( /:$/ ){
$dir_line = 1;
}
elsif( /\S/ && ! /\S+\s\S+/ ){
# Probably a start of directory without a trailing :
# (export.lcs.mit.edu outputs these)
s/$/:/;
$dir_line = 1;
}
if( $dir_line && ! $last_was_blank ){
print "\n";
}
print;
$last_was_blank = /^$/;
$last_was_dir = $dir_line;
}

View File

@ -0,0 +1,375 @@
#!/usr/local/bin/perl
# Used with permission by Bunyip Information Systems
#
# This program filters raw ls listings files to produce a file that archie
# can parse. It started life as the filt program in the original archie
# distribution and was converted to perl and modified by Amos Shapira.
# Then significant modifications and improvements, as well as many hours of
# testing, were done by Eric Anderson at SURAnet (eanders@sura.net).
#
# Please report any bugs or send any patches to archie-admin@sura.net
# Also regular expression gurus should feel free to comment what various
# undocumented sections of the code actually does.
#
# Notes:
# Need to add to fixpermerrors a check for whatever stupid thing the site
# is sticking onto the front.
# SITES we do not handle yet:
# eba.eb.ele.tue.nl
# harvard.harvard.edu
# biox.unibas.ch
# garbo.uwasa.fi
# inria.inria.fr
# thumper.bellcore.com
# Filter version 1.0.4
$debuglevel=0;
# Debuglevels:
$\ = "\n"; # automatically add newline on print
@legit = ("[dl-]","[r-]","[w-]","[xsS-]","[r-]","[w-]",
"[xsS-]","[r-]","[w-]","[x-]",
"(\\d| )","(\\d| )","(\\d| )","[ \\d\\w]","[ \\d\\w]");
#for ($loop=
# Legit patterns for chars in permission part of line.
$fulllegit = join("",@legit);
$aixlegit = join("","^[DF]",@legit[1..9]);
$dirperms = join("",'d',@legit[1..9]);
$permlegit = join("","^",@legit[0..9]);
$idlegit = "^(\\w|\\d|-)+$";
#print "'$dirperms'";
$badchar = "[^ -~\\t]";
$corruptpattern = join('',$badchar,".*",$badchar,".*",$badchar,".*");
$filenamebegin= -1; # Automagically initialized on the first directory.
$printedaline=0;
$maxdiraddsize=40;
$curdir="";
undef @basedirs;
$lastline="@@@beginning";
for (;<>;) {
chop;
# Commented out study because it was making some stuff break, I don't
# quite know why, below is code which breaks if it is below the study.
# print "$_";
# print "MOOOOF" if /$dirperms/o;
# next;
# study;
die ("@@@ Belch -- Corrupted input?\n") if /$corruptpattern/o;
# If any of these cases are true, the line is not printed.
# Remove totaling lines
next if (/^total[ \t]+\d+[ \t]*$/o);
next if (/^Total:[ \t]+\d+[ \t]*kbytes$/o);
# Something with opendir in it.
next if (/^opendir:/o);# {
# Toss we are in europe lines
next if (/WE ARE IN EUROPE/o);
# Don't print character or block devices.
next if (/[cb][-rwxSsTt]{9}/o);
# Chuck lines having that pattern in them.
next if (/can not access/o);
# Chuck lines as seen below.
next if (/stale nfs file handle/io);
# Another bizarre case
next if (/^\.:?$/o);
# Throw away leading blank lines
next if (/^$/ && !$printedaline);
# I wonder what this does.
next if (/^[ \t]/o);
# Throw away lines containing unreadable.
next if (/unreadable/o);
# Throw away lines which have : no /dev/zero at the end of them
next if (/: no \/dev\/zero$/o);
# Throw away lines which have No such file or directory in them
next if (/No such file or directory$/o);
# Throw away lines with crt0: no /usr/lib/ld.so -- for sparta.spartacus.com
next if (/^crt0: no \/usr\/lib\/ld.so$/o);
# Throw away short lines which aren't blank and aren't directories.
# First seen on cs.tut.fi
next if ((length($_)<10)&&(!/:$/o)&&(!/^$/o)&&!(/^\.|\//o));
next if ((length($_)<$filenamebegin) && /^$fulllegit/o &&
!(/Permission denied/o||/not found/o||/cannot access/o));
# Throw away ld.so warnings
next if (/^ld.so: warning: /o);
# Throw away more ld.so errors
next if (/^ld.so: map heap error \(22\) for \/dev\/zero/o);
# Throw away the line ${org}: for eba.eb.ele.tue.nl
next if (/^\$\{org\}\:$/o);
# Throw away lines with connection timed out for ftp.informatik.rwth-aachen.de
next if (/^ls:.*Connection timed out$/o);
# Throw away this line for aix370.rrz.uni-koeln.de
next if (/^\.disk1\:$/o);
# Remove blank lines which precede filename entries so that enter doesn't
# think they are supposed to be directory names.
if (/^$/o) {
$_ = <STDIN>;
# print STDERR "$_"; # ***
last if !defined $_;
chop;
if (!/^$fulllegit/o) {
print "";
$lastline = "";
$_ .= " "; # For the chop to eat.
redo;
}
}
if ($filenamebegin<0&&/^$dirperms/o) {
$filenamebegin = length($_);
do {
--$filenamebegin;
die ("filenamebegin dropped too much??") if $filenamebegin<20;
} until ((substr($_,$filenamebegin,1) eq " ")&&
(substr($_,$filenamebegin-2,1) =~ /\d/o));
++$filenamebegin;
}
# Make sure we don't get stuck in a loop.
$count=0;
$start=$_;
# This forces idempotency. the loop that is.
do {
++$count;
die("@@@ iterated for a long time on \n'$start'\n, never got done.\n") if $count>50;
# warn("@@@ iterations:$count") if $count>2;
$orig = $_;
# Try to put : after dir names in listing.
# bin:
# files
if ((/^\./o || /^\//o) && /\w$/o && !/Permission denied/o) {
print "";
$lastline = "";
$_ = "$_:";
}
# Dump a return in if the last line was all printable chars with a colon
# on the end, e.g. a directory, and the last line was for real.
if (!/^$fulllegit/o) {
print "" if (/^[\w\/+#-\.]+:$/o && $lastline);
# Remove an extra color from a directory name entry if it exists.
# For wuarchive.wustl.edu
s/::$/:/o;
}
#General cleanup
# Hack out garbage people put on front of listings.
if (/^\//o || /^\./o) {
s!^\./!!o;
s!^/usr/spool/ftp/!!o;
s!^/pub/!!o;
s!^/usr/local/pub/!!o;
s!^/home/ftp/pub/!!o;
s!^/ftp/pub/!!o;
s!^/com/ftp/pub/!!o;
s!^/var/spool/uucppublic/!!o;
s!^/com/ftp/sun4/pub/!!o;
s!^/users/ftp/!!o;
s!^.disk1/!!o; # For aix370.rrz.uni-koeln.de
}
# What's this do?
# s/^([-dl][-rwxSsTt]{9}.*)(\\$)/$1/o;
# s/^([-dl][-rwxSsTt]{9})(\d+)/$1 $2/o;
# Take out trailing / from directory listing
s/^(d.*)\/$/$1/o;
# Take :'s off the end of lines which aren't really directories names.
# Why would I want to do this? Note I still do.
# Do this so that the next line will work right.
s/^($fulllegit.*)\:$/$1/o;
# Hack for walhalla.informatik.uni-dortmund.de, user/group names with
# spaces in them.
s/NOT FTP/NOT_FTP/go;
# Hack for gargoyle.uchicago.edu, to fix directory with return in the name
if (/^pub\/emwq\/Mailboxes.*h$/o) {
$_ .= ":";
$foo = <STDIN>;
}
# Two hacks for eba.eb.ele.tue.nl
if (/^l.*local.$/o) {
s/^l(.*local)./d$1/o;
}
if (/^pub\/apollo\/local\/News\:$/o) {
print "pub/apollo/local:";
print "drwxrwxrwx 1 news 15 Mar 15 12:00 News";
print "";
}
#Put space between permissions and id.
if (/^[ld-][r-][w-][x-]/o && /^..........\d/o) {
s/^(..........)/$1 /o;
if (substr($_,$filenamebegin-1,2) eq ' ') {
substr($_,$filenamebegin-1,2) = ' ';
}
}
#Fix AIX bogosity
if (/$aixlegit/o) {
# Aix ls follows directory symlinks.
s/ \-\> .*$//o if (/^D/o && / \-\> /o);
s/^D/d/o;
s/^F/-/o;
}
#Special hack for earth.rs.itd.umich.edu
if (/^mac\.bin\/\.AppleDesktop\/_:$/o && !$hack'umich_edu) {
# print STDERR "@Did hack for earth on $_."; # ***
$hack'umich_edu=1;
while(!/^$/o) {
$_=<STDIN>;
}
}
#Replace trailing spaces with underscores in directory listings.
$spacepos=rindex($_," ");
while (($spacepos>=$filenamebegin)
&&((/ _*$/o)||
(substr($_,$filenamebegin-6) =~ /^(\d| )\d(\d|\:)\d\d _* /o))) {
# Roughly that regexp is time (13:45) or year ( 1990)
s/ (_*)$/_$1/o;
substr($_,$filenamebegin-6) =~
s/^(..... )(_*) /$1$2_/o;
$spacepos=rindex($_," ");
}
#Put in leading spaces for bogus stuff.
#Ditto for the : terminated stuff.
# Also fixup anthing like foo/bar /doobie:
if (/:$/o) {
s/ (_*(:$|\/))/_$1/o while (/ _*(:$|\/)/o);
s/\/(_*) /\/_$1/o while (/\/_* /o);
}
#Complicated fixups.
if (/Permission denied/o||/not found/o||/cannot access/o||
/Connection timed out/o) {
$_ = &fixlserrors($_);
next if (! $_);
}
} until ($orig eq $_);
if (/^$dirperms/o) { # && length($_)<$maxdiraddsize) {
$dirname=$curdir . substr($_,$filenamebegin);
if (length($dirname) <$maxdiraddsize) {
push(@basedirs,$dirname);
# print STDERR "Adding '",$dirname,"' to dir list";
}
}
$curdir = substr($_,0,length($_)-1)."/" if (/:$/o);
$lastline = $_;
print;
$printedaline=1;
}
sub fixlserrors {
local ($_) = @_;
local ($first);
local ($count);
# print STDERR "Enter FixLsErrors";
# return "" if /^ls.*denied$/o;
return "" if /^(\/bin\/)?ls.*denied$/o;
# return "" if /^ls.*not found$/o;
return "" if /^(\/bin\/)?ls.*not found$/o;
return "" if /^cannot access /o;
return "" if /^lost\+found: Permission denied$/o;
# $foodebug=1 if $_ =~ /tesol: Per/;
$first = &fixpermline($_);
# print STDERR "*1$first" if $foodebug;
$count = 0;
$_ = undef;
while (!$_) {
# print STDERR "Hi";
++$count;
die ("@@@ FixLsErrors iterated too long :$count\n") if $count>200;
$_ = <STDIN>;
last if !defined($_);
# print STDERR "*a$count,$first,$_"; #***
# print STDERR "'$_'" if defined $_;
chop ;
last if /^$/o;
# print STDERR "*b$count,$first,$_"; #***
if (/denied$/o) {
$_ = "";
} else {
$_ = &fixpermline($_);
}
# print STDERR "*c$count,$first,$_"; #***
}
# print STDERR "*d$first" if $foodebug;
# print STDERR "@*$first,$_" if /pleD/o;
# print STDERR "*e$first" if $foodebug;
$_= $first . $_;
# print STDERR "*&&$_" if $foodebug;
return $_ if /^$fulllegit/o;
return $_ if /^.*:$/o;
return "";
}
sub fixpermline {
local ($_) = @_;
local ($count);
# print "@$_@";
# sys13 stuff for potemkin.cs.pdx.edu
s/(\/bin\/)?ls\s*:.*denied( \(sys13\))?$//o;
s/(\/bin\/)?ls\s*:.*not found$//o;
s/\.\/.*not found$//o;
s/cannot access .*$//o;
s/\.\/.*Connection timed out:$//o;
# print STDERR "*$_*";
return $_ if !(/Permission denied/o || /not found/o || /cannot access/o ||
/Connection timed out/o);
$rightmost=0;
$longlen=0;
foreach $elem (@basedirs) {
# if ($foodebug&&rindex($_,$elem)>=0) {
# print STDERR "@$elem";
# print STDERR "@$elem,", rindex($_,$elem);
# print STDERR "@", rindex($_,"mac/incoming");
# }
if (0<=($foo=rindex($_,$elem))) {
$bar = length($elem);
# print STDERR "@@$foo,$rightmost,$bar,$longlen,", $rightmost-$bar-1;
if ($foo>=($rightmost-$bar-1)) {
# Backup by at most by the length of the current one.
# Plus a /
$longlen=$bar;
$rightmost=$foo;
# print STDERR "!$_,$elem,$longlen,$rightmost" if /incoming\/pal/;
}
}
}
# if ($rightmost>0&&$foodebug) {
# print STDERR "Found:", substr($_,$rightmost);
# print STDERR "Returning:" , substr($_,0,$rightmost);
# }
if (/$fulllegit/o) {
$_ = substr($_,0,$rightmost);
} else {
return substr($_,0,$rightmost) if (($rightmost>0) &&
!(substr($_,$rightmost-1,1) eq "/"));
# print STDERR "nope";
}
local($acc,$orig) = ("",$_);
local(@line) = split(//o,$_);
local($x,$m);
local(@legitcopy) = @legit;
$count=0;
do {
++$count;
die ("@@@ fixpermline iterated too long:$count\n") if $count>50;
$_ = shift @line;
$m = shift @legitcopy;
# print STDERR "#$m#$_#$acc";
return $acc if !/$m/; # Don't put the o here, this changes.
# print STDERR "##$acc";
$acc .= $_;
} until $#legitcopy==-1;
$_=$orig;
s/\:\s*Permission denied//o;
s/\/(\w|\/)*\s*not found//o;
return $_;
}

View File

@ -0,0 +1,122 @@
#!/usr/local/bin/perl
#
# $Id: filter_anonftp_unix_bsd,v 1.1 1995/01/11 08:03:50 lucb Exp $
#
$non_crud = $perm_denied = $not_found = "";
while( <> ){
# Stomp on carriage returns
s/\015//g;
# Try and spot crud in the line and avoid it
# You can get:
# -rw-r--r-ls: navn/internett/RCS/nsc,v: Permission denied
# ls: navn/internett/RCS/bih,v: Permission denied
# - 1 43 daemon 1350 Oct 28 14:03 sognhs
# -rwcannot access .stuff/incoming
# cannot access .stuff/.cshrc
# UX:ls * .. this was found in IRIX systems recently. The whole line
# should be ignored (Bibi Oct-5-95)
if( m%^(.*)/bin/ls:.*Permission denied% ||
m%^UX:ls:.*Permission denied% ||
m%^(.*)ls:.*Permission denied% ||
m%^(.*)(cannot|can not) access % ){
if( ! $non_crud ){
$non_crud = $1;
}
next;
}
# Also try and spot non ls "Permission denied" messages. These
# are a LOT harder to handle as the key part is at the end
# of the message. For now just zap any line containing it
# and the first line following (as it will PROBABLY have been broken).
#
if( /.:\s*Permission denied/ ){
$perm_denied = 1;
next;
}
if( $perm_denied ){
$perm_denied = "";
# warn "Warning: input corrupted by \"Permission denied\" errors, about line $. of $lsparse'name\n";
next;
}
# Not found's are like Permission denied's. They can start part
# way through a line but with no way of spotting where they begin
if( /not found/ ){
$not_found = 1;
next;
}
if( $not_found ){
$not_found = "";
# warn "Warning: input corrupted by \"not found\" errors, about line $. of $lsparse'name\n";
next;
}
if( $non_crud ){
$_ = $non_crud . $_;
$non_crud = "";
}
# Just ignore all these kinds of line
if( /^([-dl][-rwxSsTt]{9}).*\s(\d+)\s*\w\w\w\s+\d+(\s(\d\d\d\d)\s\s)(.*)$/ ){
s%$3% $4 %;
}
if( (/^([-dl][-rwxSsTtl]{9}).*\s(\d+)\s*(\w\w\w\s+\d+\s*(\d+:\d+|\d\d\d\d))\s+(\.|\.\.)$/ ) ||
/^total[ ][ ]*[0-9][0-9]*[ ]*$/ ||
/^ls:(\s*)total[ ][ ]*[0-9][0-9]*[ ]*$/ ||
/^Total:[ ][ ]*[0-9][0-9]*[ ]*kbytes$/ ||
/^opendir:.*$/ ||
/^\.:$/ ||
/^\.$/ ||
/^.*[ ][ ]*unreadable?[ ]*$/ ||
/^[cb][-rwxSsTt]\{9\}/ ||
/^ld.so: warning: / ||
/^crt0: no / ||
# These next 4 lines are to remove the crap at the start of the
# nikhefh.nikhef.nl listing
/This is:/ ||
/NIKHEF-H, National Institute/ ||
/Kruislaan 409, P.O. Box/ ||
/Questions to:/ ||
# Not sure about where this one comes from.
/WE ARE IN EUROPE/ ){
next;
}
s%^\./%%;
s%^/usr/spool/ftp/%%;
s%^/pub/%%;
s%^/usr/local/pub/%%;
s%^/home/ftp/pub/%%;
s%^/ftp/pub/%%;
s%^/com/ftp/pub/%%;
s%^/com/ftp/sun4/pub/%%;
s%^/var/spool/uucppublic/%%;
# -rw-r--r--+ from ghost.dsi.unimi.it (lucb)
s%^([-cbdlrwxSsTt]{10})\+%$1 %;
local( $dir_line );
s%^([-dl][-rwxSsTt]{9})([0-9]+)%$1 $2%;
if( /^([-dl][-rwxSsTt]{9}).*\s(\d+)\s*(\w\w\w\s+\d+\s*(\d+:\d+|\d\d\d\d))\s+(.*)$/ ){
$file_line = 1;
s,/$,,;
}
elsif( /:$/ ){
$dir_line = 1;
}
elsif( /\S/ && ! /\S+\s\S+/ ){
# Probably a start of directory without a trailing :
# (export.lcs.mit.edu outputs these)
s/$/:/;
$dir_line = 1;
}
if( $dir_line && ! $last_was_blank ){
print "\n";
}
print;
$last_was_blank = /^$/;
$last_was_dir = $dir_line;
}

View File

@ -0,0 +1,51 @@
#!/bin/sh
# $Id: filter_anonftp_unix_bsd.sed,v 1.1 1995/01/11 08:03:53 lucb Exp $
# Trash leading /usr/spool/ftp from uunet
# /home/ftp/pub for xview
# ./ from aix.rpi.edu (for example)
# /bin/ls from everything
# .: from chyde.uwasa.fi (for example)
# put space between permissions and links if they bump into one another
# -rw-r--r--+ from ghost.dsi.unimi.it (lucb)
sed ' /^total[ ][ ]*[0-9][0-9]*[ ]*$/d
/^Total:[ ][ ]*[0-9][0-9]*[ ]*kbytes$/d
/^opendir:.*$/d
/^.*[ ][ ]*unreadable[ ]*$/d
s/^\.\///
s/^\/usr\/spool\/ftp\///
s/^\/pub\///
s/^\/usr\/local\/pub\///
s/^\/home\/ftp\/pub\///
s/^\/ftp\/pub\///
s/^\/com\/ftp\/pub\///
s/^\/var\/spool\/uucppublic\///
/WE ARE IN EUROPE/d
s/^\([-cbdlrwxSsTt]\{10\}\)+/\1 /
s/^\([-dl][-rwxSsTt]\{9\}.*\)\(\\$\)/\1/
s/^\([-dl][-rwxSsTt]\{9\}\)\([0-9][0-9]*\)/\1 \2/
/[cb][-rwxSsTt]\{9\}/d
/\/bin\/ls.*Permission denied$/{
N;
s/\/bin\/ls.*Permission denied[ ]*//
}
/ls.*:.*Permission denied$/{
N;
s/ls.*:.*Permission denied[^ !-~]*//;
}
/\/bin\/ls.*not found$/{
N;
s/\/bin\/ls.*not found[^ ]*//
}
/.*not found$/{
N;
s/.*not found[^ ]*//
}
/can not access/d
/^[^ ]*:/{
i\
}
/^d[-rwxSsTt]\{9\}.*\/$/s/\/$//
/^\.:/d'

View File

@ -0,0 +1,3 @@
#!/bin/sh
sed s/ //g

7
release/scripts/mail_handler Executable file
View File

@ -0,0 +1,7 @@
#!/bin/sh
fbase=zzz$$
rm -f Info MailHeader
sed -e '/@Begin/,/@MailHeader/w Info' -e '/@MailHeader/,/@End/w MailHeader' \
-e '/@Begin/,/@End/d' | \
(ms_size=`sed -n 's/^MaxSplitSize: //p' < Info` ; cat Info ; echo $ms_size ; split_file -s $ms_size -f $fbase)

74
release/scripts/mail_inform Executable file
View File

@ -0,0 +1,74 @@
#!/bin/sh -u
#
# We handle the output, from the telnet and e-mail clients, that is to
# be mailed to the user.
#
prog=`basename $0`
REPLY_ADDR='archie-group@bunyip.com'
usage()
{
cat - <<EOC
Usage: $0 email-addr filename
EOC
exit 1
}
fatal()
{
echo ""
echo "${prog}: $1"
exit 1
}
if [ $# -ne 2 ] ; then
usage
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)
# - cat
# - echo
# - wc
# - grep
# - rm
PATH=/usr/bin:/usr/ucb:/usr/lib:bin
tmp=/tmp
# Must use quotes
mailcmd="sendmail -t -f$REPLY_ADDR"
# --------------- End Configure --------------------
umask 077
trap do_trap 1 2 3 15
if [ -r $2 ] ; then
cat $2| $mailcmd $1
fi
exit 0

107
release/scripts/mail_receiver Executable file
View File

@ -0,0 +1,107 @@
#!/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. /usr/ucb/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/ucb:/usr/lib:bin
#PATH=/usr/bin:/usr/ucb:/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

103
release/scripts/mail_stats Executable file
View File

@ -0,0 +1,103 @@
#!/bin/sh
ch_etc()
{
if p=`grep "^archie:" /etc/passwd` ; then
archiehome=`echo $p | awk -F: '{print $6}'`
elif p=`ypmatch archie passwd` ; then
archiehome=`echo $p | awk -F: '{print $6}'`
fi
cd $archiehome/etc
}
MAIL_PGM=/usr/ucb/mail
ARCHIE_USER=archuser
MAIL_PREFIX=mail
RES_FILE=$MAIL_PREFIX.results
ADD_FILE=$MAIL_PREFIX.add
DEL_FILE=$MAIL_PREFIX.delete
SUC_FILE=$MAIL_PREFIX.success
FAI_FILE=$MAIL_PREFIX.fail
PAR_FILE=$MAIL_PREFIX.parse
RET_FILE=$MAIL_PREFIX.retr
ch_etc
if [ -w $RES_FILE ] ; then
cp /dev/null $RES_FILE
(
if [ -r $RET_FILE ]; then
echo " ";
echo " ";
echo "Failed retrieve:";
echo " ";
echo " ";
cat $RET_FILE
fi
if [ -r $PAR_FILE ]; then
echo " ";
echo " ";
echo "Failed parse:";
echo " ";
echo " ";
cat $PAR_FILE
fi
if [ -r $ADD_FILE ]; then
echo " ";
echo " ";
echo "Sites added:" ;
echo " ";
echo " ";
cat $ADD_FILE;
fi
if [ -r $DEL_FILE ]; then
echo " ";
echo " ";
echo "Sites deleted:";
echo " ";
echo " ";
cat $DEL_FILE;
fi
if [ -r $SUC_FILE ]; then
echo " ";
echo " ";
echo "Successful updates:";
echo " ";
echo " ";
cat $SUC_FILE;
fi
if [ -r $FAI_FILE ]; then
echo " ";
echo " ";
echo "Failed updates:";
echo " ";
echo " ";
cat $FAI_FILE
fi
) >> $RES_FILE
sub="archie update results `date`"
cat $RES_FILE | mail -s "$sub" $ARCHIE_USER
rm -f $ADD_FILE
rm -f $DEL_FILE
rm -f $SUC_FILE
rm -f $FAI_FILE
rm -f $PAR_FILE
rm -f $RET_FILE
fi

57
release/scripts/process-email Executable file
View File

@ -0,0 +1,57 @@
#!/bin/sh
#
# process-email (c) Copyright Bunyip Information Systems, Inc. 1994
#
# This routine can be used to batch incoming email requests for later
# processing
#
# Modified by Lee McLoughlin for Solaris 2.3 <lmjm@doc.ic.ac.uk>
#
PATH=/bin:/usr/bin:/usr/ucb
if p=`grep "^archie:" /etc/passwd` ; then
archiehome=`echo $p | awk -F: '{print $6}'`
elif p=`ypmatch archie passwd` ; then
archiehome=`echo $p | awk -F: '{print $6}'`
fi
ch_tmp()
{
cd $archiehome/db/tmp
}
usage() {
echo "Usage: batch-email -t <tmp dir>"
exit 1
}
tdir="notset"
while [ $# -gt 1 ] ; do
case $1 in
#temp directory
-t) if [ $# -gt 1 ] ; then shift ; tdir=$1; else usage; fi;;
esac
shift
done
if [ $tdir = "notset" ]; then
ch_tmp
else
cd $tdir
fi
for i in aremail.*; do
# $archiehome/bin/email-client -i $i $*
if ($archiehome/bin/email-client < $i) ; then
/bin/rm -f $i
else
/bin/mv -f $i FAILED_$i
fi
done

238
release/scripts/prospero-stats.pl Executable file
View File

@ -0,0 +1,238 @@
#!/usr/local/bin/perl
# -*- perl -*-
#
# Archie-stats.pl - gather Archie statistics and print them out.
#
# 1995 (c) Bunyip Information Systems Inc.
# written by Luc Boulianne <lucb@bunyip.com>
#
# $Id: prospero-stats.pl,v 1.2 1995/03/12 22:53:41 lucb Exp $
#
;# require "getopts.pl";
;# Actual routine has been appended at the end of this file.
;# Several sites did not have perl properly set up.
& Getopts("hs:");
if (defined($opt_h)) {
print "archie-stats - examine logfiles and produce a summary report
usage: archie-stats [-h] [-s servername] < logfile
-h this message
-s servernname over-ride local hostname
";
exit;
}
if (defined($opt_s)) {
$server = $opt_s;
}
if ($server eq "") {
chop($server = `hostname`);
}
$date = time;
chop $date;
printf "#\n# Archie Statistics Report\n#\n";
printf "# server: %s\n", $server;
printf "# local : %s\n", &strtime(localtime($date));
printf "# utc : %s\n", &strtime(gmtime($date));
%month =
(Jan,'01',Feb,'02',Mar,'03',Apr,'04',May,'05',Jun,'06',
Jul,'07',Aug,'08',Sep,'09',Oct,10,Nov,11,Dec,12);
%searchtypes = (
'=', exact,
'R', regex,
'r', 'exact regex',
'X', 'string only regex',
'x', 'string only exact regex',
'C', subcase,
'c', 'exact subcase',
'K', 'string only subcase',
'k', 'string only exact subcase',
'S', substring,
's', 'exact substring',
'Z', 'string only substring',
'z', 'string only exact substring',
'n', 'string only exact',
);
printf "# date@time str rqs| ";
foreach $type (sort keys(%searchtypes)) {
printf "%s ", $type;
}
printf " |exn rxmt cach mtchs time q\n";
print '#', '-' x 79, "\n";
$prevdhkey = "";
sub report {
local ($key) = @_;
local ($date,$hour) = split('@',$key);
local ($i);
printf "%s@%s00 ", $date, $hour;
printf "%s", $startups{$key}==0 ? "-" : $startups{$key};
printf " %4d |", $requests{$key};
$buf = "";
foreach $type (sort keys(%searchtypes)) {
if ($buf ne "") { $buf .= " "};
$i = int($subrequests{$key,$type});
$buf .= sprintf("%s", $i==0 ? "-" : $i);
}
printf "%-32s|", $buf;
printf "%3d ", $expands{$key};
printf "%4d ", $retrans{$key};
printf "%3d ", $cached{$key};
printf "%6d ", $matches{$key};
printf "%4.1f ", $total_time{$key}/$time_ests{$key};
printf "%2s\n", $queued{$key}==0 ? "-" : $queued{$key};
}
while (<>) {
# Build our key
chop;
next if ! (/^(..)-(...)-(..).*/o);
($day,$time,$host,$rest) = split(' ',$_,4);
($di,$dm,$dy) = split('-',$day);
$day = sprintf("%02d",$dy) . $month{$dm} . sprintf("%02d",$di);
$dhkey = $day . "@" . substr($time,0,2);
if (($dhkey ne $prevdhkey) && ($prevdhkey ne "")) {
&report($prevdhkey);
$lastrep = $prevdhkey;
}
$prevdhkey = $dhkey;
if ($rest =~ "ARCHIE/MATCH") {
$cmd = (split("/",$rest,3))[1];
$type = substr($cmd,rindex($cmd,",")+1,1);
$requests{$dhkey} += 1;
$subrequests{$dhkey,$type} += 1;
next;
}
if ($rest =~ "ARCHIE/HOST") {
$expands{$dhkey} += 1;
next;
}
if ($rest =~ "Retransmitting") {
$retrans{$dhkey} += 1;
next;
}
if ($rest =~ "matches") {
$matches{$dhkey} += (split(":", $rest))[1];
next;
}
if ($host =~ "matches") { # Old server
$matches{$dhkey} += $rest;
next;
}
if ($rest =~ "Responding") { # Old server (cached data)
$cached{$dhkey} += 1;
next;
}
if ($host =~ "Responding") { # Old server (cached data)
$cached{$dhkey} += 1;
next;
}
if ($rest =~ "Est time:") {
$total_time{$dhkey} += (split(":",$rest,2))[1];
$time_ests{$dhkey} += 1;
next;
}
if (($rest =~ "Queued") && !($rest =~ "Priority")) {
# printf "[%s]\n",$rest;
if ($rest =~ "of") {
# printf "{%s}",((split(/\s/,$rest,6))[4]);
$queued{$dhkey} = &MAX($queued{$dhkey},(split(/\s/,$rest,6))[4]);
} else {
$queued{$dhkey} = &MAX($queued{$dhkey},(split(/\s/,$rest,4))[2]);
}
next;
}
if (($host =~ "Startup")) {
$startups{$dhkey} += 1;
next;
}
}
if ($dhkey ne $lastrep) {
&report($prevdhkey);
}
sub MAX {
local($max) = pop(@_);
foreach $foo (@_) {
$max = $foo if $max < $foo;
}
$max;
}
sub strtime {
local($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = @_;
local(@DoW) = ('Sun','Mon','Tue','Wed','Thu','Fri','Sat');
local(@MoY) = ('Jan','Feb','Mar','Apr','May','Jun',
'Jul','Aug','Sep','Oct','Nov','Dec');
local($[) = 0;
$year += ($year < 70) ? 2000 : 1900;
sprintf("%s %s %2d %02d:%02d:%02d %s%4d",
$DoW[$wday], $MoY[$mon], $mday, $hour, $min, $sec, $TZ, $year);
}
;# getopts.pl - a better getopt.pl
;# getops.pl (c) Part of the Perl distribution
;#
;# Included here for portability...[lucb@bunyip.com]
;#
;# Usage:
;# do Getopts('a:bc'); # -a takes arg. -b & -c not. Sets opt_* as a
;# # side effect.
sub Getopts {
local($argumentative) = @_;
local(@args,$_,$first,$rest);
local($errs) = 0;
local($[) = 0;
@args = split( / */, $argumentative );
while(@ARGV && ($_ = $ARGV[0]) =~ /^-(.)(.*)/) {
($first,$rest) = ($1,$2);
$pos = index($argumentative,$first);
if($pos >= $[) {
if($args[$pos+1] eq ':') {
shift(@ARGV);
if($rest eq '') {
++$errs unless @ARGV;
$rest = shift(@ARGV);
}
eval "\$opt_$first = \$rest;";
}
else {
eval "\$opt_$first = 1";
if($rest eq '') {
shift(@ARGV);
}
else {
$ARGV[0] = "-$rest";
}
}
}
else {
print STDERR "Unknown option: $first\n";
++$errs;
if($rest ne '') {
$ARGV[0] = "-$rest";
}
else {
shift(@ARGV);
}
}
}
$errs == 0;
}

132
release/scripts/rotate Executable file
View File

@ -0,0 +1,132 @@
#!/bin/sh
#
# Make backup copies of a specified file ( arg. 1 ). A second argument, <n>
# is optional and specifies that you want to keep <file>.0 through <file>.<n>
# as backups. If no number is given then the default, 6, will be used.
#
# - wheelan
#
# Heavily Modified by lucb for compression and presentation. Backwards
# compatible to Bill's version
#
usage () {
cat <<EOC
Usage: $0 [-v] [-d directory] [-c] [-n] file [number]
$0 makes backup copies of a specified file. A second argument,
\`number' is optional and specifies that you want to keep \`file.0'
through \`file.n' as backups. If no number is given then the default
\`9' will be used.
Compressed files [files ending in .Z or .gz] are checked for and moved
appropriately. In addition, if a compressed file is found, the newly
moved file will be compressed. The appropriate compression program is
used.
EOC
exit 2
}
#
# parse the command line arguments:
#
while [ $# -gt 1 ] ; do
case $1 in
-d) shift; directory=$1;;
-c) compression="y";;
-n) compression="n";;
-v) verbose="y" ;;
-x) set -x ;;
-h) usage;; # call the usage funtion
[a-zA-Z0-9]*) break;;
*) # Catch anything that doesn't match the
# previous flags
echo "Unknown option [$1]";
usage;;
esac
shift
done
if [ $# -lt 1 -o $# -gt 2 ] ; then
usage;
fi
if [ ! -f $1 ] ; then
echo "File $1 does not exist"
exit 1
fi
debug()
{
if [ x$verbose = xy ] ; then
echo "$1"
fi
}
index()
{
i=1;
while [ $i -le ${1:-$MIDX} ] ; do
echo -n "$i ";
i=`expr $i + 1`;
done
}
rindex()
{
i=${1:-$MIDX};
while [ $i -gt 0 ] ; do
echo -n "$i ";
i=`expr $i - 1`;
done
}
directory=${directory:-.}
if [ "${directory}" != "." ] ; then
if [ ! -d $directory ] ; then
echo "Can't find directory [$directory]"
exit 2
fi
fi
umask 000
compress=none
for n in `rindex ${2:-9}` ; do
src=${directory}/$1.`expr $n - 1`
dst=${directory}/$1.$n
if [ -d $src -o -f $src ] ; then
/bin/mv -f $src $dst && debug "/bin/mv -f $src $dst"
compress=none
elif [ -f $src.Z ] ; then
/bin/mv -f $src.Z $dst.Z && debug "/bin/mv -f $src.Z $dst.Z"
compress=compress
elif [ -f $src.gz ] ; then
/bin/mv -f $src.gz $dst.gz && debug "/bin/mv -f $src.gz $dst.gz"
compress=gzip
fi
done
# A copy would keep the file permissions the same, but will fill in "holes"
# in the file.
dst=$directory/$1.0
perm=`perl -e '$mode=((stat("'$1'"))[2] & 07777); printf ("%o\n", $mode)'`
mv $1 $dst && debug "mv $1 $dst"
cat /dev/null > $1
chmod $perm $1 && debug "chmod $perm $1"
if [ x${compression:-} = xn ] ; then
debug "No compression requested";
elif [ x${compression:-} = xy ] ; then
gzip $dst && debug "gzip $dst (explicitely)" ;
else
case "$compress" in
"none")
debug "No compression";;
"compress")
compress $dst && debug "compress $dst" ;;
"gzip")
gzip $dst && debug "gzip $dst" ;;
esac
fi

10
release/scripts/show_arcompress Executable file
View File

@ -0,0 +1,10 @@
#!/bin/sh
for i do
x=`grep -n @header_end $i | awk -F: '{print $1}'`
head -$x $i | sed s/compress_lz/raw/
x=`expr $x + 1`
tail +$x $i | zcat | sed s/ //
echo ""
echo ""
done

35
release/scripts/start-weaseld Executable file
View File

@ -0,0 +1,35 @@
#!/bin/sh
get_home()
{
if [ $# -ne 1 ] ; then
fatal "get_home: bad number of arguments"
fi
if p=`grep "^${1}:" /etc/passwd` ; then
echo $p | awk -F: '{print $6}'
elif p=`ypmatch $1 passwd` ; then
echo $p | awk -F: '{print $6}'
else
fatal "get_home: can't find home directory for $1"
fi
}
check_uid_root()
{
id=`id | sed 's/(.*$//' | sed 's/^.*=//'`;
# echo "Your uid is $id";
if [ "$id" -ne "0" ]; then
echo "Warning! Weaseld will not start unless you are running it as root"
echo " or you're running with the -debug flag"
fi
}
HOME=`get_home archie`
check_uid_root;
if $HOME/bin/weaseld -user archie -proot /MENU/gopher.archie_release $* ; then
echo "";
else
echo "Problem starting weaseld";
fi

144
release/scripts/trimplog.pl Executable file
View File

@ -0,0 +1,144 @@
#!/usr/local/bin/perl
# -*- perl -*-
#
# trimplog.pl - perl script to trim log files.
#
# 1995 (c) Bunyip Information Systems Inc.
# written by Luc Boulianne <lucb@bunyip.com>
#
# $Id: trimplog.pl,v 1.2 1995/03/12 22:53:40 lucb Exp $
#
;# require "getopts.pl";
;# Actual routine has been appended at the end of this file.
;# Several sites did not have perl properly set up.
& Getopts("hd:g:v");
if (defined($opt_h)) {
print "trimplog - split the pfs log file by day.
usage: trimplog [-h] [-d directory] [-g y|n]
-h this message
-d directory directory where to store the trimmed log files
-g y|n gzip is available? yes or no
-v verbose
";
exit;
}
if (defined($opt_v)) {
$verbose="y";
}
if (defined($opt_d)) {
$directory = $opt_d;
} else {
$directory = ".";
}
if (defined($opt_g)) {
if ($opt_g ne "y") {
$compress = "";
& debug ("gzip is not available\n");
} else {
$compress = "|gzip -c ";
& debug ("gzip is available\n");
}
} else {
$compress = "";
}
%month =
(Jan,'01',Feb,'02',Mar,'03',Apr,'04',May,'05',Jun,'06',
Jul,'07',Aug,'08',Sep,'09',Oct,'10',Nov,'11',Dec,'12');
$tag="";
$oday="";
while (<>) {
if (/^(..)-(...)-(..).*/o) {
$day = sprintf("%02d",$1); $mon = $2; $year = $3;
if ($day ne $oday) {
if ($tag ne "") {
close (OUTLOG) || die "Can't close $logfile: $!";
}
$oday = $day;
$tag = $year.$month{$mon}.$day;
if ($compress eq "") {
$logfile = $directory . "/pfs.log" . $tag ;
$outlog=">> $logfile";
} else {
$logfile = $directory . "/pfs.log" . $tag . ".gz";
$outlog="$compress>> $logfile";
}
& debug ("$outlog\n");
open (OUTLOG, $outlog) ||
die "Can't pipe/append to $outlog: $!";
# print STDERR $logfile,"\n";
}
print OUTLOG $_;
} elsif (! /dirsrv: Bad recvfrom n = -1 errno = 9 Bad file number/) {
if ($tag ne "") {
print OUTLOG $_;
}
}
}
;# getopts.pl - a better getopt.pl
;# getops.pl (c) Part of the Perl distribution
;#
;# Included here for portability...[lucb@bunyip.com]
;#
;# Usage:
;# do Getopts('a:bc'); # -a takes arg. -b & -c not. Sets opt_* as a
;# # side effect.
sub Getopts {
local($argumentative) = @_;
local(@args,$_,$first,$rest);
local($errs) = 0;
local($[) = 0;
@args = split( / */, $argumentative );
while(@ARGV && ($_ = $ARGV[0]) =~ /^-(.)(.*)/) {
($first,$rest) = ($1,$2);
$pos = index($argumentative,$first);
if($pos >= $[) {
if($args[$pos+1] eq ':') {
shift(@ARGV);
if($rest eq '') {
++$errs unless @ARGV;
$rest = shift(@ARGV);
}
eval "\$opt_$first = \$rest;";
}
else {
eval "\$opt_$first = 1";
if($rest eq '') {
shift(@ARGV);
}
else {
$ARGV[0] = "-$rest";
}
}
}
else {
print STDERR "Unknown option: $first\n";
++$errs;
if($rest ne '') {
$ARGV[0] = "-$rest";
}
else {
shift(@ARGV);
}
}
}
$errs == 0;
}
sub debug {
local($string) = @_;
if ($verbose eq "y") {
print $string;
}
}

93
release/scripts/unrotate Executable file
View File

@ -0,0 +1,93 @@
#!/bin/sh
#
#
# 1994 (c) Regents of McGill University, School of Computer Science.
# by Luc Boulianne (lucb@cs.mcgill.ca)
#
usage () {
cat - <<EOC
Usage: $0 [-h] [-v] files.[0-9]
Interactively, unrotate a group of files in the current directory. You must
supply only one copy of the filename group you want to unrotate. If you
don't, a set of files will be unrotated twice.
Options:
[-v] set debugging on
[-h] this help info
EOC
exit 2
}
# parse the command line arguments:
#
if [ $# -gt 0 ] ; then
case $1 in
-v) debug="y" ; shift;;
-h) usage;; # call the usage funtion
-*) # Catch anything that doesn't match the
# previous flags
echo "Unknown option [$1]";
usage;;
esac
fi
MV=/bin/mv
TAR=tar
GZIP=gzip
MIDX=9;
# For solaris ...
PATH=/usr/ucb:$PATH
index()
{
i=1;
while [ $i -le ${1:-$MIDX} ] ; do
echo -n "$i ";
i=`expr $i + 1`;
done
}
rindex()
{
i=${1:-$MIDX};
while [ $i -gt 0 ] ; do
echo -n "$i ";
i=`expr $i - 1`;
done
}
unrotate()
{
fn=$1;shift;
test -f $fn && $MV -f $fn $fn.new && echo $MV -f $fn $fn.new
test -f $fn.0 && $MV -f $fn.0 $fn && echo $MV -f $fn.0 $fn
for n in $* ; do
echo [$n]
dest=$fn.`expr $n - 1`
src=$fn.$n
test -f $src && $MV -f $src $dest && echo $MV -f $src $dest
done
}
idx=`index`;
if [ x${debug:-x} = yx ] ; then
set -x;
fi
for i do
file=`echo $i | sed 's/\.[0-9]$//'`
echo ${file}*
echo -n "Proceed with the unrotation of the [${file}*] group of files? [n] "
read ans
if [ x$ans = xy ] ; then
unrotate $file $idx && echo "Unrotated files ${file}*"
fi
done

98
release/scripts/untar Executable file
View File

@ -0,0 +1,98 @@
#!/bin/sh
#
# Untar a file safely by making backup of the files your are about to
# overwrite.
#
# 1994 (c) Regents of McGill University, School of Computer Science.
# by Luc Boulianne (lucb@cs.mcgill.ca)
#
usage () {
echo "Usage $0 [-v] [-d directory] tarfile.gz"
echo "Untar files safely by making backup of the files you"
echo "are about to overwrite."
echo "options: "
echo " [-d] cd to this directory before untarring"
echo " [-v] set debugging on"
echo " [-h] this help info"
echo ""
exit 2
}
# parse the command line arguments:
#
while [ $# -gt 1 ] ; do
case $1 in
-d) shift; directory=$1;;
-v) debug="y" ;;
-h) usage;; # call the usage funtion
*) # Catch anything that doesn't match the
# previous flags
echo "Unknown option [$1]";
usage;;
esac
shift
done
umask 000
MV=/bin/mv
TAR=tar
GZIP=gzip
MIDX=9;
# For solaris ...
PATH=/usr/ucb:$PATH
echo "Untarring $1 in the ${directory:=.} directory.";
index()
{
i=1;
while [ $i -le ${1:-$MIDX} ] ; do
echo -n "$i ";
i=`expr $i + 1`;
done
}
rindex()
{
i=${1:-$MIDX};
while [ $i -gt 0 ] ; do
echo -n "$i ";
i=`expr $i - 1`;
done
}
rotate()
{
fn=$1;shift;
for n in $* ; do
src=$fn.`expr $n - 1`
dest=$fn.$n
test -f $src && $MV -f $src $dest && echo " - $MV -f $src $dest"
done
test -f $fn && $MV -f $fn $fn.0 && echo " - $MV -f $fn $fn.0"
}
idx=`rindex`;
if [ x${debug:-x} = yx ] ; then
set -x;
fi
echo ""
echo "Uncompressing the tar file - this will take a moment..."
echo ""
echo "Note: Please do not interrupt while files are being rotated."
echo " The simple script, \`unrotate' has been supplied to unrotate files in"
echo " a given directory, should something go wrong."
echo ""
$GZIP -d < $1 | $TAR -tf - | while read file
do
cd $directory
echo $file
test -f $file && rotate $file $idx && echo "Rotated old file $file"
done
$GZIP -d < $1 | (cd $directory ; $TAR -xvpf - )