#/bin/bash

# A little script to update the FreeS/WAN snapshot
# By Claudia Schmeing
# Jan 20, 2004

# just to be sure...
cd /vol/www/www.freeswan.org/web-docs/freeswan_snaps/
ncftpget ftp://ftp.xs4all.nl/pub/crypto/freeswan/development/snapshot.tar\*


# Check md5sum.

md5sum snapshot.tar.gz > snapshot.tar.gz.localmd5

if ( cmp snapshot.tar.gz.localmd5 snapshot.tar.gz.md5 )
then
  # md5sum checks out, so put snap on the web.
   

  # Since there is no easy way of telling them apart once the other file
  # is unpacked...
  rm -rf freeswan-snap*
  rm CURRENT-SNAP

  tar -zxf snapshot.tar.gz
  ln -s freeswan-snap* CURRENT-SNAP

  # temporary workaround
  if (  ! test -a CURRENT-SNAP/doc/upgrading.html )
  then
    # snapshot compile still broken.
    cp -p  CURRENT-SNAP/doc/src/*  CURRENT-SNAP/doc
  fi

  mail -s "Snapshot updated" claudia@coldstream.ca < .

else
   # problem with md5sum. Do not copy, but mail self.
   diff snapshot.tar.gz.localmd5 snapshot.tar.gz.md5 | mail -s "Problem with current snap" claudia@coldstream.ca
fi

