#!/bin/sh
set -e

me="[factory-reset]"

# Load ipmodule variables
source /opt/gira/share/devicestack/ipmodule-vars

if mount | grep "${UD_BLOCKDEV}" > /dev/null
then
  echo "${me} Userdata is mounted, abort mission."
  exit 1
else
  echo "${me} Factory reset called. Cleaning userdata partition."
  echo "${me} Reformatting ${UD_BLOCKDEV}."
  mkfs.ext3 -F ${UD_BLOCKDEV}
  sync
  echo "${me} Done."
  exit 0
fi
