head	1.20;
access;
symbols;
locks; strict;
comment	@# @;


1.20
date	97.09.18.15.52.19;	author millerm;	state Exp;
branches;
next	1.19;

1.19
date	96.09.20.14.57.22;	author millerm;	state Exp;
branches;
next	1.18;

1.18
date	96.09.18.17.23.04;	author millerm;	state Exp;
branches;
next	1.17;

1.17
date	96.04.20.21.49.46;	author millerm;	state Exp;
branches;
next	1.16;

1.16
date	96.01.21.22.22.20;	author millerm;	state Exp;
branches;
next	1.15;

1.15
date	96.01.21.21.36.48;	author millerm;	state Exp;
branches;
next	1.14;

1.14
date	96.01.02.06.47.43;	author millerm;	state Exp;
branches;
next	1.13;

1.13
date	95.12.20.09.06.55;	author millerm;	state Exp;
branches;
next	1.12;

1.12
date	95.12.10.20.54.26;	author millerm;	state Exp;
branches;
next	1.11;

1.11
date	95.11.21.00.31.52;	author millerm;	state Exp;
branches;
next	1.10;

1.10
date	95.11.20.23.53.51;	author millerm;	state Exp;
branches;
next	1.9;

1.9
date	95.11.20.23.41.32;	author millerm;	state Exp;
branches;
next	1.8;

1.8
date	95.11.13.06.21.29;	author millerm;	state Exp;
branches;
next	1.7;

1.7
date	95.10.26.05.57.55;	author millerm;	state Exp;
branches;
next	1.6;

1.6
date	95.10.23.20.44.55;	author millerm;	state Exp;
branches;
next	1.5;

1.5
date	95.10.23.20.26.49;	author millerm;	state Exp;
branches;
next	1.4;

1.4
date	95.10.23.19.19.49;	author millerm;	state Exp;
branches;
next	1.3;

1.3
date	95.10.12.21.54.27;	author millerm;	state Exp;
branches;
next	1.2;

1.2
date	95.10.12.19.16.22;	author millerm;	state Exp;
branches;
next	1.1;

1.1
date	95.10.12.18.59.07;	author millerm;	state Exp;
branches;
next	;


desc
@this is the script that does stuff to the archive... It's big
ugly and right now, really outdated and messy.

 - Mike
@


1.20
log
@Added \ to delimit the @@ in printed email addresses so that the
script is now Perl5 compatable.
@
text
@#!/usr/local/bin/perl
#
############################################################################
# The origional of this script is kept under RCS control DO NOT EDIT until #
# you have checked out a locked copy of the script!!!                      #
############################################################################
#
# build - a perl script for automating the administration of ftp
# 	archives. Created by Mike Miller, September 1994.
# 	use the command `build help` to see the documentation.
#

# location of the gifs
$leftgif = "/pub/next/admin/a_left.gif";

# html information
$siteurl = "ftp://next-ftp.peak.org";

# site information
$sitetop = "/info/ftp/pub/next";
# the number of characters to strip off the path to translate it
# into a ftp directory
$ntrans = 9;

#location of executeables
$gzip = "/usr/local/gnu/bin/gzip";
$compress = "compress";

# first thing to do is to get the date of this whole darn thing
# since I timestamp a lot of stuff there isn't any sense in
# executing date over and over again since date doesn't need
# to be that accurate

$date = `date`;
chop $date;

# I leave most of my debug code in. It's done with if statements. It
# probably makes the code slower due to the increased number of if
# statements, but it's not such a pain in the butt to debug when
# something goes wrong...
$idescend_debug = 0;
$deep_debug = 0;
$diag = 0;

if (@@ARGV == 0) {
# no arguments isn't very fun, tell the user about it.
	print STDERR "Usage: build option [option]\n";
	print STDERR "type `build help` for assistance\n";
	exit;
}

foreach $arg (@@ARGV) {
# if we have some arguments then decide what to do based on those
# arguments. Here is a nice case statement to do the job
	print STDOUT "Inside the loop with $arg\n";
	CASE: {
		if ($arg =~ /^archive/) { &build_archive;last CASE; }
		if ($arg =~ /^index/) { &idecend("$sitetop");last CASE; }
		if ($arg =~ /^recents/) { &recents;last CASE; }
		if ($arg =~ /^sindex/) { &submission_index; last CASE; }
		if ($arg =~ /^.index/) { &refresh_index; last CASE; }
		if ($arg =~ /^modes/) { &odecend; last CASE; }
		if ($arg =~ /^misc/) { &misc; last CASE; }
		if ($arg =~ /^help/) { &help; last CASE; }
		print STDOUT "$arg is not a valid option for build.\n";
		print STDOUT "Type `build help` to get a list of valid choices and help\n";
	}
}
exit;

# That was the main body of the program. Below this point
# there are merely subroutines (and lots of them)

sub help {
# guess what? This is the big help stuff that we print to tell
# users all the wonderful things that this program can do.
	print STDOUT <<"end_of_help";

build 1.1ALPHA4						Sept 18, 1997

	A perl program designed to assist in the maintence of the
	next archive at next-ftp.peak.org. (previously at
	ftp.cs.orst.edu) It has several features:
		Recursive index building and maintance.
		Submission directory monitoring.
		Automatic change of permissions. *** Currently Broken ***

	There are currently 6 possible arguments that build takes.

	archive - This preforms a total reconstruction of the archive
		including indexing, linking, and creation of
		informational files.

	index - This recursivly builds up a index of the entire
		archive from the .index files that are also created
		or updated on the fly. The result is a .index file
		in every subdirectory with the contents of the
		subdirectory, and a index file with the contents
		of that subdirectory and the contents of all
		subdirectories underneath it. Also builds a cute
		little html document in each directory called
		files.html that is a html verison of the .index at
		each level.

	.index - This creates or updates a single .index file in
		the current directory. This file can have descriptions
		of the files added to it by leaving a space after
		the filename and adding text. The additional text
		is preserved through the indexing process providing
		that it is on the same line as a valid file, and 
		there is a space between the filename and the text. 

	modes - This changes the directories to be mode 775 and
		regular files to be 664. It is a recursive calling
		function that does not modify the current directory
		that it is in, only the subdirectories of itself.
		*** CURRENTLY BROKEN ***

	misc -  This just takes care of a couple little things.
		Compresses and gzips copies of the top level index
		file as well as ls-lR.

	recents - This creates a called Recent_Arrivals that finds
		all files that have a last modified date of 7 or
		less days.

	sindex - This creates a index file for the submissions
		directory that is diffrent from the standard
		index file in that it seperates out the files by
		arrival times. It also mails the file to the
		administrative alias.

	help - Creates this text and outputs it to standard output.

EXAMPLES
	Say you have just moved a lot of files around and you want
	to add descriptions to the .index files and update the
	archive because you had to reorganize some major areas.
	to get a new .index file in the directory you are in:
		build .index
	Now you can edit the .index file to add the descriptons
	Then maybe you want to update the entire index structure.
		build index
	Now that the index is cleared up you realize that you
	need to move a few more files around so you do that, and
	just to update everything you rebuild the entire archive
		build archive
	now everything is updated and everyone should be happy.

BUGS
	Plenty, it isn't very robust yet and does *very* little
	error checking. I wouldn't reccomend moving it off of
	next-ftp.peak.org unless you know perl pretty well.

HISTORY
	build was created by Mike Miller September 1994. It
	contains some stuff that is coded specifically to
	the next-ftp.peak.org archive. be careful if you try
	to use it elsewhere.

	Second Coding October 1995 by Mike Miller

	1.0ALPHA  - This version was a working prototype.
		parts of it don't even run to syntatcal errors
	1.1ALPHA  - Massive changes, it does different things
		and in diffrent ways...
	1.1ALPHA2 - Modifications to fix bugs and add html
		 features.
	1.1ALPHA3 - Moved the script to next-ftp.peak.org this
		 move required many little changes and caused
		 the creation of several global variables that
		 were specific to the site instead of hardcoding
		 imbedded in the code
        1.1ALPHA4 - Added '\' character to delimit @@ in printed
		 email addresses. This makes the script Perl5
		 compatable

AUTHORS
	Just me so far. If you use this, write me mail and let
	me know what you think. This is version 1.1ALPHA so don't
	expect too much.

	millerm\@@ece.orst.edu

end_of_help
}

sub build_archive {
# pretty self explanatory, it goes through and runs everything
	chdir "$sitetop";
#	&odecend; # IT IS BROKEN
	&idecend ("$sitetop");
	&recents;
	&submission_index;
	&misc;
}

sub misc {
# This takes the index file in the top directory and creates
# gziped and compressed versions of the index
	chdir "$sitetop";
	`cp index index.bak`;
	unlink ("index.gz");
	`$gzip -9 index`;
	`cp index.bak index`;
	unlink ("index.Z");
	`$compress index`;
	`mv index.bak index`;
	@@listing = `ls -LlRF`;
	$pwd = `pwd`;
	print "$pwd";
	open (FILE, ">$sitetop/ls-lR") || die "Can't open the ls-lR file for some reason";
	foreach $file (@@listing) {
		print FILE "$file"
	}
	close (FILE);
	chdir "$sitetop";
	`cp ls-lR ls-lR.bak`;
	unlink("ls-lR.gz");
	`$gzip -9 ls-lR`;
	`cp ls-lR.bak ls-lR`;
	unlink("ls-lR.Z");
	`$compress ls-lR`;
	`mv ls-lR.bak ls-lR`;
}

sub idecend {
# this builds all the .index and index files throughout the tree
# it gets passed the directory it has just entered
	local($thisdir, @@junk) = @@_;
	opendir(CDIR, ".");
	local(@@filelist) = grep(!/^.\.?$/, readdir(CDIR));
	closedir(CDIR);
	local ($file);
	foreach $file (@@filelist) {
		if($deep_debug){print STDOUT " the file is $file\n";}
		local ($todir) = "$thisdir/$file";
		if ( ($todir) && ( -d $todir ) )
		{
			chdir "$todir";
			if($idescend_debug){print("entering $todir\n");}
			&idecend ($todir);
			chdir "$thisdir";
			if($idescend_debug){print("entering $thisdir\n");}
		}
	}
	&refresh_index ($thisdir);  # updates the .index
	&build_index ($thisdir); # builds (destructivly) the index file from the
		                 # index files below (ain't recursion great?)
}

sub odecend {
# this bit of code is to change the ownership of the files to 664
# over the entire directory structure without moshing the permissions
# on the soft links and on the directories. If you know of a better
# way to do this please contact me. This method strikes me as messy
        local(@@filelist) = `ls -1F`;
        local ($file);
        foreach $file (@@filelist) {
                chop $file;
                #print STDOUT "This is the file at the top of odecend $file\n";
                if ( (-d $file) && ($file) && ($file !=~/submissions/) ) {
                        #print STDOUT "moving into $file\n";
                        chdir "$file";
                        &odecend;
			local (@@listing) = `ls -1F`;
			if (-f ".index") {
				push (@@listing, ".index\n");
			}
			local ($tobec);
			foreach $tobec (@@listing) {
				chop $tobec;
				#print STDOUT "trying to change mode of $tobec\n";
				if ( -d $tobec ) {
					#print STDOUT "directory $tobec\n";
					local (@@broke) = grep(!(chmod 0775, $_), $tobec);
					if (@@broke) {
						$pwd = `pwd`;
						print STDOUT "$0: couldn't chmod @@broke inside of $pwd";
					}
				}
				else {
					#print STDOUT "file $tobec\n";
					local (@@broke) = grep(!(chmod 0664, $_), $tobec);
					if (@@broke) {
						$pwd = `pwd`;
						print STDOUT "$0: couldn't chmod @@broke inside of $pwd";
					}
				}
			}
                        local ($pwd) = `pwd`;
                        print STDOUT "moving out of $pwd";
                        chdir "..";
                }
        }
}

sub refresh_index {
# This little piece is responsible for updating/creating the .index
# files. There are one or two little tricks that you would need to
# change if you are using this at a site other than next-ftp.peak.org
	local($thisdir, @@junk) = @@_;
	if ( -e ".index" ) {
		open (ORIG, ".index") || die "Can't open .index, refresh_index";
		local (@@origional);
		while (<ORIG>) {
# OK a word of explination, I'm going to build an associative array
# with the key being the (almost) full pathname of the file
# and the contents are the description.
			local ($name, $description) = split(' ',$_,2);
			chop $description;
			$origional{$name} = $description;
			#print "$name, $origional{$name}\n";
		}
		close ORIG;
	}
	substr ($thisdir,0,$ntrans) = ''; # this makes it so that "absolute" pathname
				  # matches in ftp and mosaic
	open (INDEX, ">.index") || print "Can't open .index for output while in $thisdir\n";
	open (HTML, ">files.html") || print "Can't open files.html for output while in $thisdir\n";
	print HTML "<title>Index for $siteurl$thisdir</title>\n";
	print HTML "<H4>Index for $siteurl$thisdir</H4>\n";
	print HTML "Last Updated $date<hr>\n";
	if ( -e "../files.html" )
	{
		print HTML "<img src=\"$leftgif\"><a href=\"../files.html\"><b> up one level</b></a><dl>";
	}
	else
	{
		print HTML "<img src=\"$leftgif\"><a href=\"../\"><b> up one level</b></a><dl>";
	}
	local (@@filelist) = `ls -1`;
	local ($file);
	foreach $file (@@filelist) {
		chop $file;
		$current = "$thisdir/$file";
		print INDEX "$current \t$origional{$current}\n";
		if( -d $file )
		{
			print HTML "<dt><b><a href=\"$file/files.html\">$file</a></b><dd> $origional{$current}<p>\n";
		}
		else
		{
			print HTML "<dt><a href=\"$file\">$file</a><dd> $origional{$current}<p>\n";
		}
	}
	print HTML "</dl>\n<hr><i>This list is automatically generated. If it appears to be out of date or corrupted please contact next-ftp\@@mail.peak.org. Thank you</i>\n";
	close (INDEX);
	close (HTML);
}

sub build_index
{
# this piece of code builds the index file based on the index files
# in it's immedate subdirectories and the .index file in the current
# directory
	local ($thisdir, @@junk) = @@_;
	opendir(CDIR, ".");
	local(@@filelist) = grep(!/^.\.?$/, readdir(CDIR));
	closedir(CDIR);
	open (INDEX, ">index") || print "Can't open index for output at $thisdir\n";
	substr($thisdir,0,$ntrans) = '';#here is "absolute" pathname mod.
	print INDEX "Index for $siteurl$thisdir\n";  #oohhh, a URL
	print INDEX "Last Updated $date\n\n";
	open (CINDEX, ".index") || print "Can't open .index for input to index";
	while (<CINDEX>)
	{
		print INDEX "$_";
	}
	close CINDEX;
	foreach $file (@@filelist)
	{
		if (($file) && ( -r "$file/index" ))
		{
			print INDEX "\n";
			open (SINDEX, "$file/index") || die "Can't open index at $thisdir\n";
			while (<SINDEX>)
			{
				print INDEX "$_";
			}
			close (SINDEX);
		}
	}
	close (INDEX);
}

sub recents {
# more fun... This creates a file called Recent_Arrivals and puts the output
# of a find -type f -mtime +7 (and some greps) in the file all nice and
# pretty (including another one of those ftp style absolute filenames)
	open (FILE, ">$sitetop/Recent_Arrivals") || die "can't open recent\n";
	local (@@list);
	local ($file);
	@@list = `find $sitetop -follow -type f -mtime -7 -print | grep -v index | grep -v NextTrash | grep -v files.html`;
	print FILE "The following is a list of the files that have arrived in the past 7 days\n";
	print FILE "Last updated: $date\n\n";
	foreach $file (@@list) {
		substr($file,0,$ntrans) = '';  # "absolute" pathname
		print FILE "$file";
	}
	close (FILE);
}

sub submission_index {
# This is pretty nice, it builds a special index for the submissions
# directory that breaks it down by arrival dates and then mails the
# file to our archive administration alias. Here we don't bother
# with changing the filenames around
	open (FILE, ">$sitetop/submissions/index") || die "Can't open the submissions index for some reason";
	local (@@day1);
	local (@@day2);
	local (@@week);
	local (@@forever);
	local ($file);
	print FILE "This is the submissions directory for the next archive at next-ftp.peak.org\n";
	print FILE "Regular daily report for $date\n\n";
	@@day1 = `find $sitetop/submissions -type f -mtime 1 -print | grep -v index`;
	local ($inarray) = @@day1;
	if ($inarray) {
		print FILE "Today's arrivals:\n\n";
		foreach $file (@@day1) {
			print FILE "$file";
		}
		print FILE "\n";
	}
	@@day2 = `find $sitetop/submissions -type f -mtime 2 -print | grep -v index`;
	$inarray = @@day2;
	if ($inarray) {
		print FILE "Yesterday's arrivals:\n\n";
		foreach $file (@@day2) {
			print FILE "$file";
		}
		print FILE "\n";
	}
	@@week = `find $sitetop/submissions -type f -mtime -7 -a ! -mtime -2 -print | grep -v index`;
	$inarray = @@week;
	if ($inarray) {
		print FILE "Week's arrivals:\n\n";
		foreach $file (@@week) {
			print FILE "$file";
		}
		print FILE "\n";
	}
	@@forever = `find $sitetop/submissions -type f -mtime +7 -print`;
	$inarray = @@forever;
	if ($inarray) {
		print FILE "Files that have been here a long time:\n\n";
		foreach $file (@@forever) {
			print FILE "$file";
		}
		print FILE "\n";
	}
	close (FILE);
	local ($tempval) = `/usr/bin/mail -s NeXT_FTP_Report next-ftp\@@peak.org < $sitetop/submissions/index`;
	if($diag){print STDOUT "$tempval";}
}

# Congrats! You have reached the end of the perl script.
@


1.19
log
@Trying to get gzip working in cron. Probably a path problem, so expanded
to the full path with a variable at the top of the file, $gzip and $compress
@
text
@d79 1
a79 1
build 1.1ALPHA3						Jan 21, 1996
d174 3
d183 1
a183 1
	millerm@@ece.orst.edu
d347 1
a347 1
	print HTML "</dl>\n<hr><i>This list is automatically generated. If it appears to be out of date or corrupted please contact next-ftp@@mail.peak.org. Thank you</i>\n";
d454 1
a454 1
	local ($tempval) = `/usr/bin/mail -s NeXT_FTP_Report next-ftp@@peak.org < $sitetop/submissions/index`;
@


1.18
log
@Adjusted settings for troi.peak.org and changed open failures to prints
instead of dies to get around permission problems in the submissions dir.
@
text
@d25 4
d201 1
a201 1
	`gzip -9 index`;
d204 1
a204 1
	`compress index`;
d217 1
a217 1
	`gzip -9 ls-lR`;
d220 1
a220 1
	`compress ls-lR`;
@


1.17
log
@Fixed the /pub/next/pub/next problem in the indexes.
@
text
@d1 1
a1 1
#!/usr/local/gnu/bin/perl
d20 1
a20 1
$sitetop = "/newinfo/data/ftp/pub/next";
d23 1
a23 1
$ntrans = 17;
d312 2
a313 2
	open (INDEX, ">.index") || die "Can't open .index for output while in $thisdir\n";
	open (HTML, ">files.html") || die "Can't open files.html for output while in $thisdir\n";
d354 1
a354 1
	open (INDEX, ">index") || die "Can't open index for output at $thisdir\n";
d358 1
a358 1
	open (CINDEX, ".index") || die "Can't open .index for input to index";
@


1.16
log
@just some debugging stuff
@
text
@d17 1
a17 1
$siteurl = "ftp://next-ftp.peak.org/pub/next";
@


1.15
log
@added the modificaitons necessary for the move to peak.org
@
text
@d1 1
a1 1
#!/usr/bin/perl
d33 8
d75 1
a75 1
build 1.1ALPHA2						Oct 12, 1995
d229 1
a229 1
		if($high_diag){print STDOUT " the file is $file\n";}
d237 1
d312 2
a313 2
	open (INDEX, ">.index") || die "Can't open .index for output";
	open (HTML, ">files.html") || die "Can't open files.html for output";
a350 1
#	local (@@filelist) = `ls -1`;
d354 2
a355 2
	open (INDEX, ">index") || die "Can't open index for output";
	substr($thisdir,0,$ntrans) = ''; # here is a "absolute" pathname modifcation.
a365 1
#		chop $file;
d369 1
a369 1
			open (SINDEX, "$file/index") || die "Can't open index for input to index";
d384 1
a384 1
	open (FILE, ">$sitetop/Recent_Arrivals");
@


1.14
log
@Just fixing some comments
@
text
@d13 12
d46 1
a46 1
		if ($arg =~ /^index/) { &idecend("/info/software/NeXT");last CASE; }
d70 2
a71 1
	next archive at ftp.cs.orst.edu. It has several features:
d141 1
a141 1
	ftp.cs.orst.edu unless you know perl pretty well.
d145 2
a146 2
	contains a lot of stuff that is coded specifically to
	the ftp.cs.orst.edu archive. be careful if you try
d151 2
a152 2
	1.0ALPHA  - This version is the current prototype.
		it might not even run to syntatcal errors
d157 5
d175 1
a175 1
	chdir "/info/software/NeXT";
d177 1
a177 1
	&idecend ("/info/software/NeXT");
d186 1
a186 1
	chdir "/info/software/NeXT";
d197 1
a197 1
	open (FILE, ">/info/software/NeXT/ls-lR") || die "Can't open the ls-lR file for some reason";
d202 1
a202 1
	chdir "/info/software/NeXT";
a215 1
#	local(@@filelist) = `ls -1`;
d285 1
a285 1
# change if you are using this at a site other than ftp.cs.orst.edu
d301 1
a301 1
	substr ($thisdir,0,5) = ''; # this makes it so that "absolute" pathname
d305 2
a306 2
	print HTML "<title>Index for ftp://ftp.cs.orst.edu$thisdir</title>\n";
	print HTML "<H4>Index for ftp://ftp.cs.orst.edu$thisdir</H4>\n";
d310 1
a310 1
		print HTML "<img src=\"/software/NeXT/admin/a_left.gif\"><a href=\"../files.html\"><b> up one level</b></a><dl>";
d314 1
a314 1
		print HTML "<img src=\"/software/NeXT/admin/a_left.gif\"><a href=\"../\"><b> up one level</b></a><dl>";
d331 1
a331 1
	print HTML "</dl>\n<hr><i>This list is automatically generated. If it appears to be out of date or corrupted please contact next-ftp@@mail.cs.orst.edu. Thank you</i>\n";
d347 2
a348 2
	substr($thisdir,0,5) = ''; # here is a "absolute" pathname modifcation.
	print INDEX "Index for ftp://ftp.cs.orst.edu$thisdir\n";  #oohhh, a URL
d377 1
a377 1
	open (FILE, ">/info/software/NeXT/Recent_Arrivals");
d380 1
a380 1
	@@list = `find /info/software/NeXT -follow -type f -mtime -7 -print | grep -v index | grep -v NextTrash | grep -v files.html`;
d384 1
a384 1
		substr($file,0,5) = '';  # "absolute" pathname
d395 1
a395 1
	open (FILE, ">/info/software/NeXT/submissions/index") || die "Can't open the submissions index for some reason";
d401 1
a401 1
	print FILE "This is the submissions directory for the next archive at ftp.cs.orst.edu\n";
d403 1
a403 1
	@@day1 = `find /info/software/NeXT/submissions -type f -mtime 1 -print | grep -v index`;
d412 1
a412 1
	@@day2 = `find /info/software/NeXT/submissions -type f -mtime 2 -print | grep -v index`;
d421 1
a421 1
	@@week = `find /info/software/NeXT/submissions -type f -mtime -7 -a ! -mtime -2 -print | grep -v index`;
d430 1
a430 1
	@@forever = `find /info/software/NeXT/submissions -type f -mtime +7 -print`;
d440 2
a441 2
	local ($tempval) = `/usr/bin/mail -s NeXT_FTP_Report next-ftp@@mail.cs.orst.edu < /info/software/NeXT/submissions/index`;
	print STDOUT "$tempval";
@


1.13
log
@they moved perl and didn't let me know... :-(
@
text
@d55 1
a55 1
build 1.1ALPHA						Oct 12, 1995
d61 1
a61 1
		Automatic change of permissions.
d75 4
a78 1
		subdirectories underneath it.
d92 1
d95 2
a96 2
			Compresses and gzips copies of the
			top level index file.
d138 1
a138 1
	1.0ALPHA - This version is the current prototype.
d140 1
a140 1
	1.1ALPHA - Massive changes, it does different things
d142 2
d158 1
a158 1
#	&odecend;
@


1.12
log
@Added a l to the ls -LRF in misc, and it should now bold all
directories in the html regions.
@
text
@d1 1
a1 1
#!/usr/local/bin/perl
@


1.11
log
@Happiness is a working script.
This now takes care of the "back one directory" problem and even includes
a small gif so that it looks really cool.
@
text
@d170 1
a170 1
	@@listing = `ls -LRF`;
d287 1
a287 1
		print HTML "<img src=\"/software/NeXT/admin/a_left.gif\"><a href=\"../files.html\"> up one level</a><dl>";
d291 1
a291 1
		print HTML "<img src=\"/software/NeXT/admin/a_left.gif\"><a href=\"../\"> up one level</a><dl>";
d301 1
a301 1
			print HTML "<dt><a href=\"$file/files.html\">$file</a><dd> $origional{$current}<p>\n";
@


1.10
log
@now using definition lists for the html and it is relative addressing
so that archive sites can use it too.
@
text
@d284 9
a292 1
	print HTML "Last Updated $date<hr>\n<dl>";
@


1.9
log
@fixed a problem with the index creation not getting the index files
below it.
@
text
@d284 1
a284 1
	print HTML "Last Updated $date<hr>";
d293 1
a293 1
			print HTML "<a href=\"ftp://ftp.cs.orst.edu$current/files.html\">$current</a> $origional{$current}<p>\n";
d297 1
a297 1
			print HTML "<a href=\"ftp://ftp.cs.orst.edu$current\">$current</a> $origional{$current}<p>\n";
d300 1
a300 1
	print HTML "<hr><i>This list is automatically generated. If it appears to be out of date or corrupted please contact next-ftp@@mail.cs.orst.edu. Thank you</i>\n";
@


1.8
log
@changed ls-lR to ls-LR to enable following of symlinks
@
text
@d210 1
a210 1
		         # index files just below (ain't recursion great?)
d305 2
a306 1
sub build_index {
d320 2
a321 1
	while (<CINDEX>) {
a324 2
	$pwd = `pwd`;
	chop $pwd;
d327 2
a328 2
		chop $file;
		if ( ($file) && ( -d $file))
a329 1
			chdir "$file";
d331 1
a331 1
			open (SINDEX, "index") || die "Can't open index for input to index";
a336 1
			chdir "$pwd";
@


1.7
log
@fixed several recursive directory problems and it now used the
opendir() commands in the creation of indexes. I would suspect
that it is far more efficient than shelling out to do every ls,
which was pretty nasty. It's amazing how much you can learn in
a year :-)
@
text
@d170 1
a170 1
	@@listing = `ls -lRF`;
@


1.6
log
@made it so recents doesn't report files.html
@
text
@d192 4
a195 1
	local(@@filelist) = `ls -1`;
d198 4
a201 7
		chop $file;
		#print STDOUT " the file is $file\n";
# the next line prevents the index from being created in the linked
# subdirectories because it isn't allowed to decend into them. If
# this works correctly things will be really cool
		if ( (-d $file) && ($file) ){
			local ($todir) = "$thisdir/$file";
d203 1
a203 1
			#print("entering $todir\n");
d310 4
a313 1
	local (@@filelist) = `ls -1F`;
d325 2
a326 1
	foreach $file (@@filelist) {
d328 2
a329 1
		if ( (-d $file) &&( $file) ) {
d333 2
a334 1
			while (<SINDEX>) {
d338 1
a338 1
			chdir "..";
@


1.5
log
@fixed minor order bug in the html index creation.
@
text
@d345 1
a345 1
	@@list = `find /info/software/NeXT -follow -type f -mtime -7 -print | grep -v index | grep -v NextTrash`;
@


1.4
log
@Fixed the find command in recents so that it follows symbolic links.
@
text
@d278 2
a285 2
	substr ($thisdir,0,5) = ''; # this makes it so that "absolute" pathname
				  # matches in ftp and mosaic
d291 8
a298 1
		print HTML "<a href=\"ftp://ftp.cs.orst.edu$current\">$current</a> $origional{$current}<p>\n";
@


1.3
log
@added rudimentary html support. The code works with symbolic links
in a rational manner now :-)

 - Mike
@
text
@d338 1
a338 1
	@@list = `find /info/software/NeXT -type f -mtime -7 -print | grep -v index | grep -v NextTrash`;
@


1.2
log
@adapted idecend and removed linking abilities. Definatly just
a test so far.
@
text
@d34 1
a34 2
		if ($arg =~ /^links/) { &build_links;last CASE; }
		if ($arg =~ /^index/) { &idecend;last CASE; }
d55 1
a55 1
build 1.0ALPHA						Sept 10, 1994
a61 2
		Linking of related subdirectories with hard links
			to prevent the problems with soft links
d63 1
a63 1
	There are currently 7 possible arguments that build takes.
a68 10
	links - This is specific to the ftp.cs.orst.edu archive.
		it builds the hard links between files in the
		binaries, demos, and sources directories. This
		results in a structure where /binaries/comm/demos
		appears to contain all the files that are in
		/demos/comm without the hassle of a soft link which
		when a cd .. in /binaries/comm/demos the soft link
		would place the user in /demos instead of
		/binaries/comm.

d132 2
d136 2
d141 1
a141 1
	me know what you think. This is version 1.0ALPHA so don't
d164 1
a164 1
	unlink (index.gz);
d167 1
a167 1
	unlink (index.Z);
d180 1
a180 1
	unlink(ls-lR.gz);
d183 1
a183 1
	unlink(ls-lR.Z);
d192 1
a192 1
	local(@@filelist) = `ls -1F`;
a193 1
	local ($flag);
d203 1
a204 1
			local ($pwd) = `pwd`;
a205 1
			$flag = '';
d208 2
a209 2
	&refresh_index;  # updates the .index
	&build_index;    # builds (destructivly) the index file from the
d263 1
d279 6
a284 4
	local (@@filelist) = `ls -1F`;
	local ($pwd) = `pwd`;
	chop $pwd;
	substr ($pwd,0,5) = '';   # this makes it so that "absolute" pathname
d289 1
a289 1
		$current = "$pwd/$file";
d291 1
d293 1
d295 1
d302 1
d305 2
a306 5
	local ($pwd) = `pwd`;
	chop $pwd;
	substr($pwd,0,5) = '';   # here is another "absolute" pathname
				 # modifcation.
	print INDEX "Index for ftp://ftp.cs.orst.edu$pwd\n";  #oohhh, a URL
@


1.1
log
@Initial revision
@
text
@d3 5
d162 1
a162 2
	&idecend;
#	&build_links;
d173 1
a173 1
	`rm index.gz`;
d176 1
a176 1
	`rm index.Z`;
d189 1
a189 1
	`rm ls-lR.gz`;
d192 1
a192 1
	`rm ls-lR.Z`;
a196 10
sub build_links {
#this is really specific to the ftp.cs.orst.edu archive
	&link('binaries','sources');
	&link('binaries','demos');
	&link('sources','demos');
	&link('sources','binaries');
	&link('demos','binaries');
	&link('demos','sources');
}

d199 2
d211 3
d215 2
a216 16
			chop $pwd;
			local ($todir) = "$pwd/$file";
			#print " $todir is made from $pwd and $file. OK?\n";
			if ( ($todir=~/binaries/ && ($todir=~/demos/ || $todir=~/sources/)) || ($todir=~/sources/ && ($todir=~/binaries/ || $todir=~/demos/)) || ($todir=~/demos/ && ($todir=~/sources/ || $todir=~/binaries/))) {
				$flag = "set";
			}
			else {
				#print STDOUT "moving into $todir\n";
				chdir "$todir";
				&idecend;
				local ($pwd) = `pwd`;
				#print STDOUT "ought to be $todir\n";
				#print STDOUT "moving out of $pwd";
				chdir "..";
				$flag = '';
			}
d220 2
a221 8
	if ($flag) {
		#print STDOUT "about to execute build_shallow_index\n";
		&build_shallow_index;
	}
	else {
		&build_index; # builds (destructivly) the index file from the
			      # index files just below (ain't recursion great?)
	}
a336 19
sub build_shallow_index {
# this piece of code builds the index file based on just the
# currently availible .index file. This is for the subdirs
# that are /binaries/something
        local (@@filelist) = `ls -1F`;
        open (INDEX, ">index") || die "Can't open index for output";
        local ($pwd) = `pwd`;
        chop $pwd;
        substr($pwd,0,5) = '';   # here is another "absolute" pathname
                                 # modifcation.
        print INDEX "Index for ftp://ftp.cs.orst.edu$pwd\n";  #oohhh, a URL
        print INDEX "Last Updated $date\n\n";
        open (CINDEX, ".index") || die "Can't open .index for input to index";
        while (<CINDEX>) {
                print INDEX "$_";
        }
        close CINDEX;
	close INDEX;
}
a408 53
sub link {
# this is the bit that builds the hard links between two subdirectories
# if you move it, realize that some of the directory structure is
# hardcoded into here and you may need to change it quite a bit.
	local($from, $to) = @@_;
	print STDOUT "$from, $to\n";
	chdir "/info/software/NeXT/$from";
	$pwd = `pwd`;
	local(@@files) = `ls -1F`;
	local($file);
	print STDOUT "the working directory is $pwd";
	foreach $file (@@files) {
		chop $file;
		chdir "/info/software/NeXT/$from";
		if ( (-d $file) && ($file) ) {
			chdir "/info/software/NeXT/$to/$file$from";
			$pwd = `pwd`;
			print STDOUT "Moved into $pwd\nBased on /$to/$file$from";
			local (@@linklist) = `ls -1`;
			if (-f ".index") {
				push (@@linklist, ".index\n");
			}
			local ($link);
			foreach $link (@@linklist) {
				print STDOUT "Inside the link removal system with $link";
				chop $link;
				if ( -e $link ) {
					$pwd = `pwd`;
					print STDOUT "I want to remove the link $link in $pwd";
					#unlink $link;
				}
			}
			chdir "/info/software/NeXT/$from/$file";
			$pwd = `pwd`;
			chop $pwd;
			print STDOUT "$pwd is the directory\n";
			local (@@fromfiles) = `ls -1F`;
			if (-f ".index") {
				push (@@linklist, ".index\n");
			}
			local ($lnfrom);
			foreach $lnfrom (@@fromfiles) {
				chop $lnfrom;
				if ( -f $lnfrom ) {
					print STDOUT "ln -s $lnfrom /info/software/NeXT/$to/$file$from/$lnfrom\n";
					#local ($temp) = `ln -s $lnfrom /info/software/NeXT/$to/$file$from/$lnfrom`;
					print STDOUT "$temp";
				}
			}
		}
	}
}
			
@
