Files
mercury/tools/generate_index_html
David Jeffery d0ee83a605 Don't include any of the index.html.$HOST files or index.html.
Estimated hours taken: 0.25


generate_index_html:
        Don't include any of the index.html.$HOST files or index.html.
test_mercury:
        Remove an extraneous `/' from a directory name.
2000-06-27 04:35:19 +00:00

57 lines
1.2 KiB
Bash
Executable File

#!/bin/sh
#
# generate_index_html
#
# Generates index.html files with a link to each file in the directory, and
# recursively for its sub-directories.
#
# Note: This script recursively calls itself, so it had better be in its
# own path!
#
INDEX=index.html.$HOST
trap 'rm -f $INDEX; exit 1' 1 2 3 13 15
#
# These are the standard locations for apache's icons
#
img_txt="<img src=/icons/text.gif>"
img_dir="<img src=/icons/folder.gif>"
img_bak="<img src=/icons/back.gif>"
echo "<H1>Directory listing</H1>" > $INDEX
echo "<hr>" >> $INDEX
echo "$img_bak <a href=../>Parent Directory</a><br>" >> $INDEX
for file in *
do
if [ `expr $file : index\.html` -ne 10 ] && [ $file != README ]
then
if [ -d $file ]
then
(cd $file && generate_index_html)
echo "$img_dir <a href=$file/>$file/</a><br>" >> $INDEX
else
size=`ls -l $file | awk '{ print $5; }'`
sizekb=`expr $size / 1024`
echo "$img_txt <a href=$file>$file</a> ($sizekb kilobytes)<br>" >> $INDEX
fi
fi
done
echo "<hr>" >> $INDEX
if [ -f README ]
then
echo "<pre>" >> $INDEX
cat README >> $INDEX
echo "</pre>" >> $INDEX
fi
chmod a+r,g+w $INDEX
chgrp mercury $INDEX
mv $INDEX index.html