#! /bin/sh

set -e

YARDCONF="/etc/yard/Config.pl"

configure() 
{
	/usr/bin/install -d /etc/yard/Replacements/etc
	/usr/bin/install -d /etc/yard/Replacements/root
	
	#    create_replacements puts files into config_dest
	/usr/share/yard/create_replacements

#	echo !
#	echo !    Now installing configuration files, which may already exist.
#	echo !    Answer \'no\' if you want to preserve your
#	echo !    existing configuration.
#	echo !				
	
	/bin/cp -ir /usr/share/yard/Replacements      /etc/yard
	/bin/cp -ir /usr/share/yard/Bootdisk_Contents /etc/yard
	/bin/cp -ir /usr/share/yard/Config.pl         /etc/yard
}

if [ -e $YARDCONF ]; then
  if [ "$1" = "--reconfigure" ]; then
        echo "Saving old conf to /etc/yard.old"
	rm -rf /etc/yard.old
  	mv /etc/yard /etc/yard.old
	mkdir /etc/yard
	configure
  else

echo "Yard it is already configured."
echo "If you want to reconfigure yard again execute: conf_yard --reconfigure"
echo "You should reconfigure yard whenever you change your kernel version."
 
  fi
else
	configure
fi

