#!/bin/sh
#
# Copyright (c) 2003-2004 Silicon Graphics, Inc.  All Rights Reserved.
# 
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
# 
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# for more details.
# 
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#
# Post installation/upgrade script for PCP
#

prog=`basename $0`
status=1
trap "exit \$status" 0 1 2 15

echo "$prog: PCP for MacOSX Install"

echo "$prog: Writing install log to /var/log/pcp_inst.log"
echo "$prog: Writing install log to /var/log/pcp_inst.log"  > /var/log/pcp_inst.log

if [ ! -d $2 ]
then
    echo "$prog: Unable to open directory of new files ($2)"
    echo "$prog: Unable to open directory of new files ($2)" >> /var/log/pcp_inst.log
    exit
fi

cd $2

if ./install-pcp -i -l /var/log/pcp_inst.log idb
then
    :
else
    echo "$prog: Install Failed"
    echo "$prog: Install Failed" >> /var/log/pcp_inst.log
    exit
fi

if [ -f /etc/pcp.conf ]
then
    # for all the configuration files we know about, salt away file
    # with a .orig suffix for a subsequent upgrade
    #
    . /etc/pcp.conf
    for conf in \
	$PCP_PMCDCONF_PATH $PCP_PMCDOPTIONS_PATH $PCP_PMCDRCLOCAL_PATH \
	$PCP_PMIECONTROL_PATH $PCP_PMLOGGERCONTROL_PATH \
	$PCP_PMPROXYOPTIONS_PATH
    do
	[ -f $conf ] && cp $conf $conf.orig
    done
fi

status=0
