meta-facebook: yosemite4: Add service for storage critical

Add service for storage critical for health monitor. It will remove
files /var/log/redfish and /home/root/ when threshold triggered.

Change-Id: I5b9adc148dd8a0226fa56bbf8699121ceeb37723
Signed-off-by: Delphine CC Chiu <Delphine_CC_Chiu@wiwynn.com>
diff --git a/meta-facebook/meta-yosemite4/recipes-phosphor/health/phosphor-health-monitor/clean-up-filesystem b/meta-facebook/meta-yosemite4/recipes-phosphor/health/phosphor-health-monitor/clean-up-filesystem
new file mode 100644
index 0000000..86313ab
--- /dev/null
+++ b/meta-facebook/meta-yosemite4/recipes-phosphor/health/phosphor-health-monitor/clean-up-filesystem
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+# clean up /var/log/redfish and files in /home/root/ which are not necessary
+rm -rf /var/log/redfish*
+rm -rf /home/root/*
diff --git a/meta-facebook/meta-yosemite4/recipes-phosphor/health/phosphor-health-monitor/clean-up-filesystem.service b/meta-facebook/meta-yosemite4/recipes-phosphor/health/phosphor-health-monitor/clean-up-filesystem.service
new file mode 100644
index 0000000..4ae3779
--- /dev/null
+++ b/meta-facebook/meta-yosemite4/recipes-phosphor/health/phosphor-health-monitor/clean-up-filesystem.service
@@ -0,0 +1,7 @@
+[Unit]
+Description=Clean up files that might full up filesystem
+
+[Service]
+Type=oneshot
+ExecStart=/usr/libexec/phosphor-health-monitor/clean-up-filesystem
+SyslogIdentifier=clean-up-filesystem
diff --git a/meta-facebook/meta-yosemite4/recipes-phosphor/health/phosphor-health-monitor_%.bbappend b/meta-facebook/meta-yosemite4/recipes-phosphor/health/phosphor-health-monitor_%.bbappend
index f99f1b8..74b3b6e 100644
--- a/meta-facebook/meta-yosemite4/recipes-phosphor/health/phosphor-health-monitor_%.bbappend
+++ b/meta-facebook/meta-yosemite4/recipes-phosphor/health/phosphor-health-monitor_%.bbappend
@@ -1,2 +1,26 @@
+FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
+
+inherit obmc-phosphor-systemd systemd
+
+SRC_URI += "file://clean-up-filesystem \
+            file://clean-up-filesystem.service \
+            "
 CPU_CRIT_TGT = ""
-MEM_CRIT_TGT = ""
\ No newline at end of file
+MEM_CRIT_TGT = ""
+STORAGE_CRIT_TGT = "clean-up-filesystem.service"
+
+RDEPENDS:${PN}:append = " bash"
+
+FILES:${PN} += "${systemd_system_unitdir}/*"
+
+SYSTEMD_SERVICE:${PN} += " \
+    clean-up-filesystem.service \
+    "
+SYSTEMD_AUTO_ENABLE = "enable"
+
+do_install:append:() {
+    install -d ${D}${datadir}/phosphor-health-monitor
+    install -m 0644 ${WORKDIR}/clean-up-filesystem.service ${D}${systemd_system_unitdir}/clean-up-filesystem.service
+    install -d ${D}${libexecdir}/${PN}
+    install -m 0755 ${WORKDIR}/clean-up-filesystem ${D}${libexecdir}/${PN}/
+}