#! /bin/sh

# $FreeBSD: databases/frontbase/pkg-install 300896 2012-07-14 13:54:48Z beat $

PATH=/bin:/usr/sbin:/usr/bin
FBUSER=frontbase
DB_DIR=${PKG_PREFIX}/FrontBase/Databases

backupwarning() { echo "

  =========== BACKUP YOUR DATA! =============
  As always, backup your data before
  upgrading. This is *NOT* done by the port!

  Press ctrl-C *now* if you need to backup.
  ===========================================
"
	sleep 5
}

licensestring() { echo "
  You will need to obtain and install a valid license string.
  Go to http://www.frontbase.com and request a license

  Once you have obtained a valid license string, install it as follows:

    Create a file ${PKG_PREFIX}/FrontBase/LicenseString with a single line
    consisting of the 64-character license string, followed by a colon (:)
    and the 16-character license check, i.e. a total of 81 characters.

  Once the license file has been installed, restart FrontBase.

  To verify that the license string has been installed correctly, 
  run ${PKG_PREFIX}/FrontBase/bin/FBInfoCenter
"
}


pre-install() {
	backupwarning
}

post-install() {
	mkdir -p ${PKG_PREFIX}/FrontBase/Backups
	mkdir -p ${PKG_PREFIX}/FrontBase/Databases
	mkdir -p ${PKG_PREFIX}/FrontBase/TransactionLogs
	chmod 750 ${PKG_PREFIX}/FrontBase/Backups
	chmod 750 ${PKG_PREFIX}/FrontBase/Databases
	chmod 750 ${PKG_PREFIX}/FrontBase/TransactionLogs
	chown -R frontbase:wheel ${PKG_PREFIX}/FrontBase/Backups \
		${PKG_PREFIX}/FrontBase/Databases \
		${PKG_PREFIX}/FrontBase/TransactionLogs
	licensestring
}

case $2 in
PRE-INSTALL)
	pre-install
	exit 0
	;;
POST-INSTALL)
	post-install
	exit 0
	;;
BACKUPWARNING)
	backupwarning
	exit 0
	;;
*)
	exit 1
	;;
esac
