#!/bin/sh

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

CHK_FACTRSTCOND_TOOL=/opt/gira/bin/chkfactrstbtnprecondition
# default value (1) executes the real factory reset check.
PRE_CONDITION_RESULT=1

case "$1" in
  start)
    echo -n "Checking factory reset pre-condition ... "
    if [ -x "${CHK_FACTRSTCOND_TOOL}" ]
    then
      ${CHK_FACTRSTCOND_TOOL}
      PRE_CONDITION_RESULT=$?
    else
      echo -n "(tool not available)"
    fi
    if [ ${PRE_CONDITION_RESULT} -eq 1 ]
    then
      echo "SET."
      ${DEVICESTACK} --check-factory-reset=${FACTORY_RESET} 2>&1 > /var/log/check-factory-reset.log
    else
      echo "NOT set."
    fi
    ;;
  stop)
    ;;
  *)
    echo "Usage: $0 (start|stop)"
    exit 1
esac
exit 0
