#!/bin/bash
echo -n "removing old FAQ...."
rm -rf linuxfaq
echo "done."
echo -n "retrieving faq from site...."
wget -q -nH -rl 1 http://localhost:8888/linuxfaq/index.jsp
wget -q -nH -rl 1 http://localhost:8888/linuxfaq/contents.jsp
# get another file separate to make sure all images come over too
wget -q -nH -rl 1 "http://localhost:8888/linuxfaq/faq.jsp?sid=020000000000"
echo "done."
echo -n "processing faq...."
cd linuxfaq
for FILE in faq.jsp*;do cat $FILE | perl -pe "s/faq\.jsp\?sid=([0-9]{12})/faq\$1.html/g" | perl -pe "s/contents\.jsp/contents.html/g" | perl -pe "s/;jsessionid.*\"/\"/" > `echo $FILE | perl -pe "s/faq\.jsp(\?sid=([0-9]{12})){0,1}/faq\\$2.html/"`;done
mv faq.html faq.html.1
cat faq.html.1 | sed "s/contents\.jsp/contents.html/g" > faq.html
rm faq.html.1
cat contents.jsp | perl -pe "s/faq\.jsp(\?sid=([0-9]{12})){0,1}(;.*){0,1}\"/faq\$2.html\"/g" | perl -pe "s/contents\.jsp/contents.html/g" > contents.html
cat index.jsp | perl -pe "s/faq\.jsp(\?sid=([0-9]{12})){0,1}(;.*){0,1}\"/faq\$2.html\"/g" | perl -pe "s/contents\.jsp/contents.html/g" > index.html
rm *.jsp*
cp -a ../mirror .
cd ..
echo "done."
echo -n "zipping up faq for sending...."
zip -r linuxfaq-`date +%d%m%y` linuxfaq
cp linuxfaq-`date +%d%m%y`.zip /home/internet/www/sites/linuxfaq/linuxfaq-web/linuxfaq.zip
echo "done."
echo "FINISHED!"
