#!/bin/sh
#
# execute this script from within the MagicStats directory...
#
# Usage: ./tarit pr14

SUFFIX=$1
MOVE=
FNPREFIX=/home/MagicStats/public_html/Downloads
if [ "$SUFFIX" = "" ]; then
  SUFFIX=`date +%Y-%m-%d`
  FNPREFIX=.
fi

DIRNAME=MagicStats2.0-${SUFFIX}
FILENAME=${DIRNAME}.tar.gz

# Remove all emacs temp files...
find . -name \*~ -exec echo removing {} \; -exec rm {} \;

cd ..
mv MagicStats $DIRNAME
tar czvf $FNPREFIX/$FILENAME $DIRNAME
mv $DIRNAME MagicStats

echo "You now have a file named $FNPREFIX/$FILENAME"
if [ "$FNPREFIX" != "." ]; then

  cd /home/MagicStats/public_html/Downloads
  rm MagicStats2.0-current.tar.gz
  ln -s $FILENAME MagicStats2.0-current.tar.gz
  echo "And an updated MagicStats2.0-current.tar.gz symlink"
fi
