#!/bin/sh
#
# Copyright (c) 2026 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.
#
# Convert an installation with original BCC PMDA to BPF.
#

. $PCP_DIR/etc/pcp.env

if grep -q ^bcc "$PCP_PMCDCONF_PATH" 2>/dev/null
then
    if grep -q ^bpf "$PCP_PMCDCONF_PATH" 2>/dev/null
    then
	sed -i -e "/^bcc.*$/d" $PCP_PMCDCONF_PATH 2>/dev/null
    else
	sed -i -e "s,^bcc.*$,bpf     157     pipe    binary          $PCP_PMDAS_DIR/bpf/pmdabpf -d 157,g" $PCP_PMCDCONF_PATH 2>/dev/null
    fi
    rm -f "$PCP_VAR_DIR/pmns/bcc" 2>/dev/null
fi

exit 0
