#!/bin/sh

# This feature simply remove everything in rw branch and reboot
# This lead to a reuse ro branch only on the next boot, as if it was the 1st factory boot
# Please note that Network configuration will be lost

[[ $1 != post ]] && exit 0

mount -t jffs2 -o sync /dev/mtdblock2 /mnt/rw_branch
rm -rf /mnt/rw_branch/*
sleep 1
umount -l /mnt/rw_branch

mount -t jffs2 -o sync /dev/mtdblock3 /mnt/rw_branch
rm -rf /mnt/rw_branch/*
sleep 1
umount -l /mnt/rw_branch


shutdown -rnP now

