#!/bin/sh

root=/tmp/gopher
PATH="${PATH}:/usr/pkg/bin"

cp -a /var/gopher $root
for file in `find $root -name gophermap`
do
  # The Gopher server at tilde.club prepends an `i' to lines that don't need it. Fix this too.
  sed -e "s/^i//g" -e "s/stone.home/tilde.club/g" -e "/tilde.club/s/\\t\\//\\t\\/~stone\\//g" $file > /tmp/gophermap

  mv -f /tmp/gophermap $file
done
rm -f $root/caps.txt
rsync -va --delete -e ssh $root/ stone@tilde.club:/home/stone/public_gopher/
if test $? -ne 0
  then logger Failed to sync gopherhole with remote server
fi
logger Successfully synced gopherhole with remote server
rm -fr $root
