Iain.Lea@anl433.uucp
Date: 02/27/93


From: Iain.Lea@anl433.uucp
Subject: getsls.sh - script to copy Linux SLS from ftp server
Date: Sat, 27 Feb 1993 22:24:22 GMT

Here's a little shell script I just put together to recursively
ftp the whole Linux SLS distribution from our local ftp server.

Iain

#!/bin/sh
# This is getsls-1.0, a shell archive (produced by shar 3.49)
# To extract the files from this archive, save it to a file, remove
# everything above the "!/bin/sh" line above, and type "sh file_name".
#
# made 02/27/1993 22:15 UTC by Iain.Lea%anl433.uucp@Germany.EU.net
# Source directory /usr/home/admin/iain/bin
#
# existing files will NOT be overwritten unless -c is specified
#
#
#
#
# This shar contains:
# length mode name
# ------ ---------- ------------------------------------------
# 2544 -rwx------ getsls.sh
#
if test -r _shar_seq_.tmp; then
        echo 'Must unpack archives in sequence!'
        echo Please unpack part `cat _shar_seq_.tmp` next
        exit 1
fi
# ============= getsls.sh ==============
if test -f 'getsls.sh' -a X"$1" != X"-c"; then
        echo 'x - skipping getsls.sh (File already exists)'
        rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting getsls.sh (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'getsls.sh' &&
X#! /bin/sh
X#
X# Script to retrieve whole Linux SLS from ftp server
X# Creates all the needed directories and fills them.
X#
X# Note1:
X# Requires NCFTP that was posted to the newsgroup
X# comp.sources.misc in Volume 35, Issue 4-7
X#
X# Note2:
X# The parsing of directory and filenames requires
X# that the index listing of files be in the format
X# used on many european ftp sites since ~1992. ie,
X# FR-- 1228800 23-Feb-1993 11:24 /pub/Linux/SLS/a1
X# FR-- 1228800 23-Feb-1993 11:15 /pub/Linux/SLS/a2
X# DR-X 0 23-Feb-1993 13:42 /pub/Linux/SLS/a3
X# FR-- 544998 23-Feb-1993 13:45 /pub/Linux/SLS/a3/base.tpz
X#
X# Note3:
X# The parsing of the path uses 'cut' which may not
X# be available on all systems (YMMV). Also not to
X# be forgotten is that you may have to fiddle about
X# with the cut's -c option to get the correct part
X# of the path for the required action. Be warned!
X#
X# Iain Lea (Iain.Lea%anl433.uucp@Germany.EU.net)
X# getsls.sh V1.0 27 Feb 1993
X
X# Ftp server that you want to get Linux from
XFTPHOST=ftp.Germany.EU.net
X
X# File that has sorted list of SLS files in the
X# ftp index format from your local ftp server
XIFILE=/optdisk/linux
X
X# Directory that you want as the root directory
X# (ie. /usr/tmp would mean /usr/tmp/SLS/...)
XODIR=/optdisk/os/linux
X
X# Temp files (automatically deleted at the end)
XDFILE=/tmp/slsdirs
XFFILE=/tmp/slsfiles
X
X# the following Un*x commands should not need to be touched
XBASENAME=basename
XCAT=cat
XCD=cd
XCUT=cut
XDIRNAME=dirname
XEGREP=egrep
XFTP=ncftp
XMKDIR="mkdir -p"
XPWD=pwd
XRM="rm -f"
XTIME=date
X
X# Record the start time
Xbegtime=`$TIME`
X
X# list all the sls directories into a temp file
X$EGREP "^D.*/SLS/[abcdstx]" $IFILE | $CUT -c65-132 > $DFILE
X
X# loop thru temp file and create directories
Xfor line in `$CAT $DFILE`
Xdo
X if [ ! -x $ODIR/$line ]
X then
X echo "$MKDIR $ODIR/$line"
X# $MKDIR $ODIR/$line
X fi
Xdone
X
X# list all the sls files into a temp file
X$EGREP "^F.*/SLS/[abcdstx]" $IFILE | $CUT -c34-132 > $FFILE
X
X# loop thru temp file
Xfor line in `$CAT $FFILE`
Xdo
X rdir=`$DIRNAME $line`
X ldir=`$DIRNAME $line | $CUT -c31-132`
X file=`$BASENAME $line`
X
X echo "Remote $CD $rdir"
X echo "Local $CD $ODIR/$ldir"
X if [ -x $ODIR/$ldir ]
X then
X $CD $ODIR/$ldir
X $PWD
X
X echo "$FTP $FTPHOST:$rdir/$file"
X $FTP $FTPHOST:$rdir/$file
X fi
X echo ""
Xdone
X
X# delete all temp files
X$RM $DFILE $FFILE
X
X# Record the end time and print both start and end times
Xendtime=`$TIME`
Xecho Beg time was $begtime
Xecho End time was $endtime
X
X# Phew! we're done
Xexit 1
SHAR_EOF
chmod 0700 getsls.sh ||
echo 'restore of getsls.sh failed'
Wc_c="`wc -c < 'getsls.sh'`"
test 2544 -eq "$Wc_c" ||
        echo 'getsls.sh: original size 2544, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
exit 0