#!/bin/sh

# This script check if there is valid config file for wine
# It runs winesetup when needed

WINE_CONFIG_PATH=/usr/lib/wine/SuSEconfig
PATH=$PATH:$WINE_CONFIG_PATH
CONFIG_FILE=$HOME/.wine/config

echo
echo "Warning: wine requests its own values in windows registry."
echo "         Please use the script 'wine_set_default_reg' to set the values."
echo "         This warning is printed every time but the update of the registry"
echo "         is needed only once after update of wine or windows." 
echo 

if is_wine_config_valid || test -f $HOME/.winerc; then
  # The configuration of wine is ok or
  # there is an old configuration file $HOME/.winerc
  # which can be actualized by wine
  exit 0
fi

echo
echo "Warning: The configuration file $CONFIG_FILE does not exist"
echo "         or it is not valid for the current version of wine"
echo "         !!! Please, ovewrite the old configuration by the winesetup !!!"
echo "         You can also use at your own risk the script:"
echo "         $WINE_CONFIG_PATH/validate_wine_config"
echo "         which will validate your current config file without"
echo "         running winesetup."
echo

validate_wine_config

winesetup

if [ -n "`grep wine/fake_windows $CONFIG_FILE`" ]; then
	regedit /usr/lib/wine/reg/winedefault.reg
fi

if [ -d ~/.wine/fake_windows/Windows/System -a ! -f ~/.wine/fake_windows/Windows/System/stdole32.tlb ] ; then
	cp /usr/lib/wine/stdole32.tlb $HOME/.wine/fake_windows/Windows/System
fi

exit 0
