#!/bin/sh
# Script to install Church Windows in a clean Wine directory
# This is rediculously hard, because Church Windows thinks it requires IE6,
# and because it needs but isn't distributed with mfc40.dll, mfc42.dll, and
# the VB 6 runtime
# (C) Dan Kegel 2005,2007
# Uses http://kegel.com/wine/winetricks to make loading runtimes easier
# For some reason, Church Windows now wants wsh, which it didn't before...?

set -e 

# Verify no existing wine
if test -d $HOME/.wine; then
   echo Please blow away $HOME/.wine first
   exit 1
fi

# Load runtimes needed by Church Windows
winetricks fakeie6 mfc40 vbrun60 vcrun6 wsh51

# Download and install Church Windows trial
test -f CW2005Trial.exe || wget -O CW2005Trial.exe http://209.190.80.19/trial/CW%202005%20Trial.exe

wine CW2005Trial.exe > cw.log 2>&1

# Install should succeed!

# Wait for install to finish
# (Should have used start /w to start installer, maybe...)
while ! test -f $HOME/.wine/drive_c/windows/fonts/USPSBar.ttf ; do
  sleep 1
done

# Now move away all fonts installed by CW to work around horrible font
# bug described in http://bugs.winehq.org/show_bug.cgi?id=3624

mkdir $HOME/.wine/drive_c/windows/badfonts
mv $HOME/.wine/drive_c/windows/fonts/*.* $HOME/.wine/drive_c/windows/badfonts


