#!/bin/bash
#
# config: 2 20
# @brief: Get the inventory information.
#

# shellcheck source=tools/dreport.d/include.d/functions
. "$DREPORT_INCLUDE"/functions

desc="inventory"

command="busctl call --verbose --no-pager \
                xyz.openbmc_project.Inventory.Manager \
                /xyz/openbmc_project/inventory \
                org.freedesktop.DBus.ObjectManager \
                GetManagedObjects"

file_name="inventory.log"

if ! add_cmd_output "$command" "$file_name" "$desc";
then
    inventory_dir="/var/lib/phosphor-inventory-manager"
    if [ -d "$inventory_dir" ]; then
        add_copy_file "$inventory_dir" "$desc"
    fi
fi
