#! /bin/sh
#
# Copyright (c) 2013 Red Hat.
# 
# 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.
# 
# Install the rpm PMDA
#

. $PCP_DIR/etc/pcp.env
. $PCP_SHARE_DIR/lib/pmdaproc.sh

iam=rpm
check_delay=3

dso_opt=true
pipe_opt=true
daemon_opt=true

if [ ! -f /var/lib/rpm/Packages ]
then
    # As of Fedora Rawhide circa Oct 2020 the RPM DB is being converted
    # from Berkeley DB to sqlite and the name of the file has changed
    #
    if [ -f /var/lib/rpm/rpmdb.sqlite ]
    then
	args="-r /var/lib/rpm/rpmdb.sqlite"
    else
	# if not either of these files is found then rpm provides no "conf"
	# file to help locate the RPM DB and there is no point continuing
	# with the PMDA installation
	#
	echo >&2 "Error: cannot find the RPM DB"
	exit
    fi
fi

pmdaSetup
pmdaInstall
exit
