#!/bin/sh
# $FreeBSD: ports/japanese/FreeWnn-server/files/pkg-install.in,v 1.2 2008/11/01 14:45:15 hrs Exp $

case $2 in
PRE-INSTALL)
	if id -u wnn > /dev/null 2>&1; then
		echo "INFO: wnn user already exists.  FreeWnn will use it."
	else
		echo "INFO: Creating 'wnn' user..."
		if pw useradd wnn -u 69 -g 7 -h - -d /nonexistent \
			-s /nonexistent -c Wnn; then
			echo "INFO: Created."
		else
			echo "ERROR: wnn user cannot create."
			exit 1
		fi
	fi
	;;
POST-INSTALL)
	case $1 in
	ja-FreeWnn-*)
		mkdir -p ${PKG_PREFIX}/lib/wnn/ja_JP/dic/usr
		chown wnn ${PKG_PREFIX}/lib/wnn/ja_JP/dic/usr
		chown wnn ${PKG_PREFIX}/bin/Wnn4/jserver
		${PKG_PREFIX}/bin/Wnn4/wnntouch \
			${PKG_PREFIX}/lib/wnn/ja_JP/dic/pubdic/* \
			${PKG_PREFIX}/lib/wnn/ja_JP/dic/wnncons/* \
			${PKG_PREFIX}/lib/wnn/ja_JP/dic/gerodic/*
		;;
	zh-FreeWnn-*)
		mkdir -p ${PKG_PREFIX}/lib/wnn/zh_CN/dic/usr ${PKG_PREFIX}/lib/wnn/zh_TW/dic/usr
		chown wnn ${PKG_PREFIX}/lib/wnn/zh_CN/dic/usr ${PKG_PREFIX}/lib/wnn/zh_TW/dic/usr
		chown wnn ${PKG_PREFIX}/bin/cWnn4/cserver ${PKG_PREFIX}/bin/cWnn4/tserver
		${PKG_PREFIX}/bin/cWnn4/cwnntouch \
			${PKG_PREFIX}/lib/wnn/zh_CN/dic/sys/* \
			${PKG_PREFIX}/lib/wnn/zh_TW/dic/sys/*
		;;
	ko-FreeWnn-*)
		mkdir -p ${PKG_PREFIX}/lib/wnn/ko_KR/dic/usr
		chown wnn ${PKG_PREFIX}/lib/wnn/ko_KR/dic/usr
		chown wnn ${PKG_PREFIX}/bin/kWnn4/kserver
		${PKG_PREFIX}/bin/kWnn4/kwnntouch \
			${PKG_PREFIX}/lib/wnn/ko_KR/dic/sys/*
		;;
	esac
esac
