#!/bin/sh
#
# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#

PKGCOND=/usr/bin/pkgcond

is_srngz=99
is_wrngz=99

if [ -x $PKGCOND ]; then
     $PKGCOND -v is_sparse_root_nonglobal_zone > /dev/null 2>&1
     is_srngz=$?
     $PKGCOND -v is_whole_root_nonglobal_zone > /dev/null 2>&1
     is_wrngz=$?
fi

##
## 'pkgcond' does not exist when you do live upgrade from S8/S9
## so in that case, use 'touch' instead for the testing
##
test_writable() {
    if [ $is_srngz -ne 99 ]; then
        $PKGCOND is_path_writable $1 && return $?
    else
        /usr/bin/touch $1/.test.$$ > /dev/null 2>&1
        if [ $? !=  0 ]; then
            return 1
        else
            rm -f  $1/.test.$$ > /dev/null 2>&1
            return 0
        fi
    fi
}

FONTINSTDIR=$BASEDIR/openwin/lib/locale/zh_TW.BIG5/X11/fonts/TT
if [ -d $FONTINSTDIR ]; then
        if test_writable $FONTINSTDIR; then
            cd $FONTINSTDIR
            if [ ! -f fonts.scale.base.ext ]; then
                if [ -f fonts.alias.old ]; then
                    mv -f fonts.alias.old  fonts.alias
                fi
                rm -f fonts.scale
            fi
            rm -f fonts.dir fonts.alias
        fi
fi

exit 0
