#!/bin/sh
#
# (cron) script to make daily news on fipsbox homepage.
#
# Written by Philip. Copy this into /etc/cron.daily/.
#

FILE="/var/www/html/home/fortunecowsay.txt"
HISTORY="/var/www/html/home/morefortunecowsay.txt"
ZITATE="/var/www/html/home/zitate.txt"
FORTUNES="/var/www/html/home/fortunes"
BACKUP="/var/www/html/www/web/old"
BOOK="/var/www/html/home/fun.php"
echo -n "Thoughts of the Cow from " > $FILE
date +%A", "%d". "%B" "%Y: >> $FILE 
/usr/games/fortune | /usr/games/cowthink >> $FILE
/usr/games/cowthink -f $(ls /usr/share/cowsay/cows/ | shuf -n1) $(/usr/games/fortune /usr/share/games/fortunes/de) >> $FILE
echo >> $FILE
cat $FILE >> $HISTORY
cat /var/www/html/web/kopf.php > $BOOK
echo "<pre>" >> $BOOK
cat $HISTORY >> $BOOK
echo "</pre>" >> $BOOK
cat /var/www/html/web/fuss.php >> $BOOK
# Following crontab entry let it run 13 minutes after each 6th full hour: 13 */6 * * * /path/fortunecowsay.sh
# Finally it is converted to an appropriate coding for the german mutated vowels
# iconv -f UTF-8 -t ISO-8859-1 $FILE > $FILE.txt
# if you use UTF-8 as charset in your homepage, you do better not do above conversion..
# date >> $FILE.history.txt
# cp -f $FILE.history.txt $BACKUP/fortunecowsaybook.txt
# Now make some extra fortunes...
# echo -n "Zitate vom fipsbox Linux Server - " > $ZITATE
# date >> $ZITATE
# echo -n "Daily fortunes from fipsbox Linux Server - " > $FORTUNES
# date >> $FORTUNES
# for ((i=1 ; i<=5 ; i++ )); do 
#	echo >> $ZITATE 
#	/usr/games/fortune /usr/share/games/fortunes/de >> $ZITATE
#	echo >> $FORTUNES 
#	/usr/games/fortune -l >> $FORTUNES
# done
# iconv -f UTF-8 -t ISO-8859-1 $ZITATE> $ZITATE.txt


