#!/bin/rc
path = (/bin .) # speed hack
rfork n
# This is ugly like hell, but it's the only way I have found to make sure hung
# junk in /srv doesn't fuck me over
prog=`{basename $0}
rm /srv/wiki.$prog
srv 'net!plan9.bell-labs.com!wiki' wiki.$prog || exit
mount -c /srv/wiki.$prog /mnt/wiki
# plan9.bell-labs is EST
cp /adm/timezone/US_Eastern /env/timezone
page='wiki index'
lastupdate=`{sed '/^D/q' < /mnt/wiki/$page/current | sed -n 's,^D,,p'}
{
echo 'Wiki Index'
echo 'D'^$lastupdate
echo 'Auriel'
echo 'Cwiki index script'
echo '
Index of wiki pages:
'
@{ cd /mnt/wiki; ls -lqQ } | awk '
$4 ~ "^d" {
id = substr($0, 8, 4)
name = $NF
nl = toupper(substr(name,1,1))
if(nl != ol)
print " \n" nl
ol = nl
gsub("_", " ", name)
printf " * [" name "] "
system("echo ''ibase=16; print " toupper(id) "''|bc|sed ''s/^.*$/(&)/''" )
}'
echo -n # Needed to 'commit' update!
} > /mnt/wiki/new
|