#!/bin/sh
#FireText Hourly Update
export TZ=Australia/Melbourne
cd ~/cron_scripts/firetext
mkdir -p public/archive/`date +\%Y/\%m/\%d`
mv public/firetext_*.txt public/archive/`date +\%Y/\%m/\%d`
runtime=`date +\%F\%T\%z`
./firetext.sh > public/firetext_$runtime.txt
lasttime=`cat firetext_lasttime`

# SFTP upload to Gopher server
echo "cd gopher/firetext/archive
-mkdir `date +\%Y`
-mkdir `date +\%Y/\%m`
-mkdir `date +\%Y/\%m/\%d`
-rename ../firetext_$lasttime.txt `date +\%Y/\%m/\%d`/firetext_$lasttime.txt
cd ..
put public/firetext_$runtime.txt
" | sftp -F /home/freet/.ssh/config -q -C -b - aussies 2>&1

echo $runtime > firetext_lasttime
