#!/sbin/sh
################################################################################
#
# File:         postinstall
# Description:  Fileset tbird-com post-installation control script.
# Purpose:	Sets directory permissions to those specified in the PSF.
#
# (c) Copyright 2006 Hewlett-Packard Development Company, L.P.
# All rights reserved.
# No part of this artifact may be reproduced without prior written permission
# from Hewlett-Packard Company.
#
################################################################################

# set environment variable DBG_SH to "set -x" to get full-script trace.
# $DBG_SH
# export DBG_SH="set -x"
# set -x

# ------------------------------------------------------------------------------
fatal_error() {
   $DBG_SH
   echo "ERROR:   $1"
   echo "         Exiting from postinstall script."
   exit 1
   }

# ------------------------------------------------------------------------------
# include standard control script functions.
UTILS="/usr/lbin/sw/control_utils"
if [ ! -f $UTILS ]; then
   fatal_error "Cannot find $UTILS"
   fi
. $UTILS
export PATH=$PATH:/usr/bin

# ------------------------------------------------------------------------------
# set directory permissions to those specified in the PSF.
if [ -n "$SW_SOFTWARE_SPEC" ]; then
   swlist -l file -a type -a mode -a uid -a gid $SW_SOFTWARE_SPEC 2>/dev/null |
   while read dir type mode uid gid; do
      if [ "$type" = "d" -a -d "$dir" -a "$dir" != "/" -a "$dir" != "/opt" ]; then
         if [ ! "$uid" -o ! "$gid" ]; then
            chmog $mode bin bin $dir
         else
            chmog $mode $uid $gid $dir
            fi
         fi
      done
   fi

# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Move short name to original name and update IPD
origdir="/opt/thunderbird/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}"
shortdir="/opt/thunderbird/extensions/short972ce4c6"
 if [[ -d $origdir ]]
  then
      rm -rf $origdir
 fi

mv $shortdir $origdir
IPD_addfile $origdir
IPD_addfile $origdir/install.rdf
IPD_delfile $shortdir/install.rdf
IPD_delfile $shortdir
# ------------------------------------------------------------------------------

exit 0
