#!/bin/sh

case ${1} in
current)
  printf "3\\n" > /opt/extparam/booted_boot_counter
  printf "Current system invalidated.\\n"
  ;;
offline)
  printf "3\\n" > /opt/extparam/offline_boot_counter
  printf "Offline system invalidated.\\n"
  ;;
fallback)
  printf "3\\n" > /opt/extparam/offline_boot_counter
  printf "Fallback system invalidated.\\n"
  ;;
both)
  printf "3\\n" > /opt/extparam/booted_boot_counter
  printf "3\\n" > /opt/extparam/offline_boot_counter
  printf "Both systems invalidated.\\n"
  ;;
*)
  printf "Error: Wrong or no parameter given.\\n"
  printf "Usage: invalidate-system <system>\\n"
  printf "Where <system> is one of the following.\\n"
  printf "  current  - Invalidates the 'current' system.\\n"
  printf "  offline  - Invalidates the 'offline' system.\\n"
  printf "  both     - Invalidates both systems.\\n"
  printf "             Info: Device will not restart until next power cycle.\\n"
  ;;
esac

exit 0
