# set up $PATH to include all the optional and bizarre places that
# useful executables might be hiding
#
for xtra in /usr/sbin /sbin /usr/local/bin $PCP_BINADM_DIR \
	    /usr/local/git/bin /usr/perl5/bin /usr/gnu/bin
do
    [ -d "$xtra" ] || continue
    if echo ":${PATH}:" | grep ":$xtra:" >/dev/null 2>&1
    then
	:
    else
	PATH="$PATH:$xtra"
    fi
done
export PATH

# migrate and clean configs
echo >>$PCP_LOG_DIR/install.log
date >>$PCP_LOG_DIR/install.log
for base in pmcd pmie pmlogger pmwebd pmproxy
do
    _clean_configs -v 2>>$PCP_LOG_DIR/install.log $PCP_SYSCONF_DIR/$base /var/lib/pcp/config/$base /etc/$base /etc/pcp/$base /etc/sysconfig/$base
done

for svc in pmproxy pmwebd pmie pmlogger pmcd pcp 
do
    [ -f $PCP_RC_DIR/$svc ] && $PCP_RC_DIR/$svc stop
    if which rc-update >/dev/null 2>&1
    then
	if rc-update show | grep " $svc " >/dev/null 2>&1
	then
	    # service is installed ...
	    #
	    rc-update delete $svc
	fi
    fi
done

for conf in \
    $PCP_PMCDCONF_PATH $PCP_PMCDOPTIONS_PATH $PCP_PMCDRCLOCAL_PATH \
    $PCP_PMIECONTROL_PATH $PCP_PMLOGGERCONTROL_PATH \
    $PCP_PMPROXYOPTIONS_PATH $PCP_PMWEBDOPTIONS_PATH
do
    if [ -f "$conf" ]
    then
	rm -f "$conf.pre"
	mv "$conf" "$conf.pre"
    fi
done

exit 0
