1#!/usr/bin/env bash
2
3declare -rx TYPE_FAULTDATA="faultdata"
4
5# @brief fetch serial number
6# @param serial number
7function fetch_serial_number() {
8    serialNo=$(busctl get-property xyz.openbmc_project.Inventory.Manager \
9            /xyz/openbmc_project/inventory/system xyz.openbmc_project.Inventory.Decorator.Asset \
10        SerialNumber | cut -d " " -f 2 | sed "s/^\(\"\)\(.*\)\1\$/\2/g")
11
12    if [ -z "$serialNo" ]; then
13        serialNo="0000000"
14    fi
15}
16
17# @brief Add BMC dump File Name
18# @param BMC Dump File Name
19function get_bmc_dump_filename() {
20    fetch_serial_number
21    dump_id=$(printf %08d $dump_id)
22    if [ $dump_type = "$TYPE_FAULTDATA" ]; then
23        header_dump_name="FLTDUMP"
24        name="NAGDUMP.${serialNo}.${dump_id}.${dDay}"
25    else
26        header_dump_name="BMCDUMP"
27        name="BMCDUMP.${serialNo}.${dump_id}.${dDay}"
28    fi
29}
30