#!/bin/sh
# Install this file as: /etc/cron.weekly/docindex
# http://crystalfaeries.net/posix/bin/cron.weekly.docindex
# celeste:crystalFaery 2016-10-05 02:34:57+00:00
# from Linux Journal 2008 August Page 91 by Bill Zimmerly
set -e
set -u
input_dir=/usr/share/doc
output_file=/usr/share/doc/index.html
cat > $output_file <<EOF
<html>
<head>
<title>$input_dir</title>
</head>
<body>
<h1 align="center">$input_dir</h1>
EOF
find $input_dir -iname 'index.html' | \
sed 's/[^ ]*/\<br\>\<a href="file:&"\>&\<\/a\>/' | \
sort >> $output_file
cat >> $output_file <<EOF
</body>
</html>
EOF
syntax highlighted by Code2HTML, v. 0.9.1