[rdkb][common][app][Add factory reset command]

[Description]
Add factory reset command

[Release-log]

diff --git a/recipes-devtools/init-filogic/files/factorydefault b/recipes-devtools/init-filogic/files/factorydefault
new file mode 100644
index 0000000..eba1b2d
--- /dev/null
+++ b/recipes-devtools/init-filogic/files/factorydefault
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+touch /reset-default
+
+reboot -f
\ No newline at end of file
diff --git a/recipes-devtools/init-filogic/init-filogic.bb b/recipes-devtools/init-filogic/init-filogic.bb
index c5215cc..6526343 100644
--- a/recipes-devtools/init-filogic/init-filogic.bb
+++ b/recipes-devtools/init-filogic/init-filogic.bb
@@ -12,6 +12,7 @@
     file://init-IPv6.service \
     file://init-bridge.sh \
     file://init-Lanbridge.service \
+    file://factorydefault \
     "
 
 RDEPENDS_${PN} += "bash"
@@ -26,6 +27,7 @@
     install -d ${D}${sbindir}
     install -m 0755 ${WORKDIR}/init-IPv6.sh ${D}${sbindir}
     install -m 0755 ${WORKDIR}/init-bridge.sh ${D}${sbindir}
+    install -m 0755 ${WORKDIR}/factorydefault ${D}${sbindir}
     install -d ${D}${systemd_unitdir}/system/
     install -m 0644 ${S}/init-IPv6.service ${D}${systemd_unitdir}/system
     install -m 0644 ${S}/init-Lanbridge.service ${D}${systemd_unitdir}/system
diff --git a/recipes-devtools/initrd/files/init_readonlyfs.sh b/recipes-devtools/initrd/files/init_readonlyfs.sh
index 703751c..f675039 100644
--- a/recipes-devtools/initrd/files/init_readonlyfs.sh
+++ b/recipes-devtools/initrd/files/init_readonlyfs.sh
@@ -38,6 +38,14 @@
 
 $MOUNT -n -t ubifs /dev/$data_ubivol -o rw,noatime /overlay
 
+if [ -f "/overlay/upper/reset-default" ]; then
+	v "Proceed with reset to default"
+	$UMOUNT /overlay
+	rootfs_data_length=$(cat /sys/class/ubi/$data_ubivol/data_bytes)
+	ubirmvol /dev/ubi0 -N rootfs_data
+	ubimkvol /dev/ubi0 -N rootfs_data -s $rootfs_data_length
+	$MOUNT -n -t ubifs /dev/$data_ubivol -o rw,noatime /overlay
+fi
 
 [ ! -d  "/overlay/upper" ] && mkdir /overlay/upper
 [ ! -d  "/overlay/work" ] && mkdir /overlay/work