bytedance: Limit coredump size

Override coredump.conf and set the max size of coredump to 2MiB.

Tested: Verify systemd removes the old coredumps and makes sure the max
        size is around 2MiB.

Signed-off-by: Lei YU <yulei.sh@bytedance.com>
Change-Id: I9ae2ba46edd2b1e1b12537f12ca09f97882a7d40
diff --git a/meta-bytedance/recipes-core/systemd/systemd-conf/coredump.conf b/meta-bytedance/recipes-core/systemd/systemd-conf/coredump.conf
new file mode 100644
index 0000000..8c3d112
--- /dev/null
+++ b/meta-bytedance/recipes-core/systemd/systemd-conf/coredump.conf
@@ -0,0 +1,8 @@
+[Coredump]
+#Storage=external
+#Compress=yes
+#ProcessSizeMax=2G
+#ExternalSizeMax=2G
+#JournalSizeMax=767M
+MaxUse=2M
+#KeepFree=
diff --git a/meta-bytedance/recipes-core/systemd/systemd-conf_%.bbappend b/meta-bytedance/recipes-core/systemd/systemd-conf_%.bbappend
new file mode 100644
index 0000000..7677eee
--- /dev/null
+++ b/meta-bytedance/recipes-core/systemd/systemd-conf_%.bbappend
@@ -0,0 +1,15 @@
+FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
+
+SRC_URI_append = " \
+    file://coredump.conf \
+"
+
+do_install_append() {
+    install -m 0644 \
+        ${WORKDIR}/coredump.conf \
+        -D -t ${D}${sysconfdir}/systemd
+}
+
+FILES_${PN}_append = " \
+    ${sysconfdir}/systemd/coredump.conf \
+"
diff --git a/meta-bytedance/recipes-core/systemd/systemd_%.bbappend b/meta-bytedance/recipes-core/systemd/systemd_%.bbappend
new file mode 100644
index 0000000..2bdee49
--- /dev/null
+++ b/meta-bytedance/recipes-core/systemd/systemd_%.bbappend
@@ -0,0 +1,3 @@
+do_install_append () {
+    rm ${D}${sysconfdir}/systemd/coredump.conf
+}