blob: 60f63640b93bfb205cb05dfb4eba33cccfed09ae [file] [log] [blame]
#!/bin/sh
OPT=$(getopt -n "$0" -o er -l i-really-mean-it,erase-backups -- "$@")
if [ $? != 0 ]; then
echo "getopt failed"
exit 1
fi
eval set -- "$OPT"
ireallymeanit=0
erasebackups=0
while true; do
case "$1" in
-r|--i-really-mean-it ) ireallymeanit=1 ;;
-e|--erase-backups ) erasebackups=1 ;;
-- ) shift; break ;;
* ) echo "***Illegal option: $1" >&2; exit 1 ;;
esac
shift
done
if [ $ireallymeanit -eq 0 ]; then
echo
echo " * * *"
echo "THIS PROGRAM WILL WIPE ALL DATA IN THE FLASH PARTITIONS!"
echo " * * *"
echo
echo -n "Are you sure (y/n)? "
read yesno
[ "$yesno" = "y" ] || exit 1
echo
ireallymeanit=1
fi
# copied from S08volcheck
check_mmc()
{
sgdisk -p /dev/mmcblk0 |
while read number start end size unit code name; do
if [ "$name" = "$1" ]; then
echo $number
fi
done
}
leds 0 15 0 15 0 15 # noisy leds as we wipe things
# try to umount what we can
pkill -9 -f miniclient
pkill -9 -f siege
pkill -9 -f dir-monitor
pkill -9 -f app_gtv
pkill -9 -f apptvg
pkill -9 -f bsa
sleep 5
(
lsof | grep /user
lsof | grep /config
) | sed -e 's/^/BUSY: /'
umount -f /config
umount -f /user
for mtdname in "data+ubi"; do
mtd=$(whichmtd "$mtdname")
if [ -n "$mtd" ]; then
echo "Wiping $mtdname ($mtd)..."
ubiformat --force -y "$mtd"
fi
done
for mtdname in "data+ext4" "userdata"; do
mtd=$(check_mmc "$mtdname")
if [ -n "$mtd" ]; then
echo "Wiping $mtdname ($mtd)..."
dd if=/dev/zero of=/dev/mmcblk0p$mtd bs=65536 count=200
fi
done
if [ $erasebackups -ne 0 ]; then
echo "Erasing backup files..."
rm -f /var/media/Wiz.bak /var/media/ManufacturingBurnin.mov
fi
leds 0 # done
echo "Rebooting in 10 seconds..."
sleep 10
reboot