Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F86856455
mkhtmlindex.sh
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Oct 9, 00:36
Size
1 KB
Mime Type
text/x-shellscript
Expires
Fri, Oct 11, 00:36 (2 d)
Engine
blob
Format
Raw Data
Handle
21493003
Attached To
rLAMMPS lammps
mkhtmlindex.sh
View Options
#!/bin/bash
if [ $# -lt 1 ]
then
echo "usage: $0 <list of directory trees to be indexed>"
exit 1
fi
for d in $(find "$@" -type d -print)
do \
dir=$(basename $d)
# index file header
cat > "$d/index.html" <<EOF
<html>
<head><title>LAMMPS-ICMS RPM Repository: $d</title></head>
<body style="font-family: mono, fixed, sans; margin-bottom: 2%; margin-top: 2%; margin-left: 5%; margin-right: 5%;">
<h1>LAMMPS-ICMS RPM Repository: $d</h1>
<h2>Contents of $dir</h2>
<hr>
<table>
<tbody>
<tr><th>[DIR]</th><th></th><th align="left"> <a href="../index.html">(Up one level)</a></th></tr>
EOF
# first all directory entries
for e in $(/bin/ls -1 "$d")
do [ "$e" = "repodata" ] && continue
[ "$e" = "drpms" ] && continue
if [ -d "$d/$e" ]
then
echo '<tr><td>[DIR]</td><td></td>' >> "$d/index.html"
echo "<td> <a href=\"$e/index.html\"> $e</a></td></tr>" >> "$d/index.html"
fi
done
# then all file entries
for e in $(/bin/ls -1 "$d")
do [ "$e" = "index.html" ] && continue
if [ -f "$d/$e" ]
then
echo '<tr><td>' >> "$d/index.html"
ls -lh "$d/$e" | cut -d \ -f 6-7 >> "$d/index.html"
echo "</td><td> <a href=\"$e\"> $e</a></td></tr>" >> "$d/index.html"
fi
done
# footer
cat >> "$d/index.html" <<EOF
</table>
</body>
</html>
EOF
done
Event Timeline
Log In to Comment