Move clear host dump service to openpower-debug-collector

Move the clear_hostdumps_poweroff.service to openpower-debug-collector
as it is needed only on IBM systems. Additionally added the scripts
to selectively delete all entries based on the dump interface to
delete only resource dump and system dump during power off.

Each type of dump will have separate service files due to difference
in activation, system dump entries are not cleared during an mpreboot

Change-Id: Ibf20b097862acb3dc7887cd75d4d5ba6bc1ff5c3
Signed-off-by: Dhruvaraj Subhashchandran <dhruvaraj@in.ibm.com>
diff --git a/dump/tools/opdump/dumpdelete b/dump/tools/opdump/dumpdelete
new file mode 100644
index 0000000..09368f0
--- /dev/null
+++ b/dump/tools/opdump/dumpdelete
@@ -0,0 +1,37 @@
+#!/bin/bash
+
+# Check if the interface parameter is provided
+if [ -z "$1" ]; then
+    echo "Usage: $0 <interface>"
+    echo "Example: $0 xyz.openbmc_project.Dump.Entry.BMC"
+    exit 1
+fi
+
+INTERFACE=$1
+
+# Run the busctl command with verbose output and capture the output
+output=$(busctl --verbose call xyz.openbmc_project.Dump.Manager \
+        /xyz/openbmc_project/dump \
+        org.freedesktop.DBus.ObjectManager \
+    GetManagedObjects)
+
+# Parse the output and print object paths containing the specified interface
+declare -A seen_paths
+
+echo "$output" | awk -v interface="$INTERFACE" '
+  /OBJECT_PATH/ {
+    path = $2;
+    gsub(/;/, "", path);
+    gsub(/"/, "", path);
+  }
+  $0 ~ interface {
+    print path;
+  }
+' | while read -r path; do
+    if [ -z "${seen_paths[$path]}" ]; then
+        echo "Deleting: $path"
+        busctl call xyz.openbmc_project.Dump.Manager "${path}" \
+            xyz.openbmc_project.Object.Delete Delete
+        seen_paths["$path"]=1
+    fi
+done