#!/bin/bash

# This to create .dat files from our fortunes

case $1 in

	clean)

		rm -fv *.dat
		rm -fv prolinux
		rm -fv *~

	;;

	help)

		echo -e "Fortunes::Pro-Linux!\
		\n\n'mkdat clean' to clean up\
		\n'mkdat' to create the cookies\n"

	;;

	*)

		x=0

		for GSCHMARRI in $(ls ????.??); do 
			y=$(sudo strfile $GSCHMARRI $GSCHMARRI.dat | grep There | gawk '{print $3}')
			echo -ne "$GSCHMARRI  contains:  $y\tcookies\n"
			x=$(($x+$y))
		done

		rm -f prolinux

		for GSCHMARRI in $(ls ????.??); do
			cat $GSCHMARRI >> prolinux
		done

		sudo strfile prolinux prolinux.dat >/dev/null

		echo -e "\noverall  cookies:   $x"

		echo -e "\ncopy prolinux{,.dat} to /usr/share/fortunes/\
		\n(may also be /usr/share/games/fortunes/)\n\n\
		try out the cookies: 'fortune prolinux'\n"

	;;

esac
