#!/bin/sh
################################################################
# VolumeCheck
#
# Check if the package can be installed on target PC.
# This script is launched at the selecting to target drive.
# 
# Created by T.KITADA
# Copyright(C) 2005 KONICA MINOLTA BUSINESS TECHNOLOGIES INC.
#
################################################################

#---------------------------------------------------------------
# Settings
#---------------------------------------------------------------
# Arguments
SCRIPT=$0
VOLUME=$1

# Action flag
# specify installer's action by return value
NO_ERROR=0	# no error : continue installation.
ERROR=32	# display message, then cancel installation.

# Message ID
#     0	: No specify (if action-flag isn't 0, use OS default. )
#  1- 2	: OS default message
#  3-15	: Reserved
# 16-31	: Use custom message in "XX.lproj/VolumeCheck.string".
MSG_INVALID_OS_VERSION=16
MSG_BLANK=17

#---------------------------------------------------------------
# Check Volume
#---------------------------------------------------------------
if [ $VOLUME != "/" ]; then
	exit `expr $ERROR + $MSG_BLANK=17`	# abort
fi

#---------------------------------------------------------------
# Get Current OS build version (only major version)
#---------------------------------------------------------------
BUILD_VER=`uname -r`	# "X.Y.Z"
BUILD_VER_1ST=`echo ${BUILD_VER%%.*}`	# X
BUILD_VER=${BUILD_VER#*.}
BUILD_VER_2ND=`echo ${BUILD_VER%%.*}`	# Y

#---------------------------------------------------------------
# Check OS version
#---------------------------------------------------------------
# - OS Build Version
VER_10_2=6
VER_10_3=7
VER_10_4=8
VER_10_5=9
VER_10_6=10

if	 [ $BUILD_VER_1ST -lt $VER_10_2 ]; then
# - before 10.2
	exit `expr $ERROR + $MSG_INVALID_OS_VERSION`	# abort
elif [ $BUILD_VER_1ST -lt $VER_10_3 ]; then
# - 10.2
	exit `expr $ERROR + $MSG_INVALID_OS_VERSION`	# abort
elif [ $BUILD_VER_1ST -lt $VER_10_4 ]; then
# - 10.3
	exit `expr $ERROR + $MSG_INVALID_OS_VERSION`	# abort
elif [ $BUILD_VER_1ST -lt $VER_10_5 ]; then
# - 10.4
	exit `expr $ERROR + $MSG_INVALID_OS_VERSION`	# abort
elif [ $BUILD_VER_1ST -lt $VER_10_6 ]; then
# - 10.5
	exit `expr $ERROR + $MSG_INVALID_OS_VERSION`	# abort
else
# - 10.6 and later
	exit `expr $NO_ERROR `			# continue
fi

#---------------------------------------------------------------
# End of Script
#---------------------------------------------------------------
exit `expr $ERROR`