#!/bin/sh

DATE_BIN=/bin/date
HWCLOCK_BIN=/sbin/hwclock
#fixed target date 2019-06-01
DEFAULT_TIME_LINUX=1559340000
DEFAULT_TIME_STRING=2019-06-01

me="[$(printf $0 | xargs basename)]"
case "$1" in
  start)
    # Check if system date prior fall back date
    SYS_DATE=$(${DATE_BIN} +%s)
    echo "${me} system date: ${SYS_DATE}"
    if [ ${SYS_DATE} -lt ${DEFAULT_TIME_LINUX} ]
    then
     ${DATE_BIN} --set "${DEFAULT_TIME_STRING}"
     ${HWCLOCK_BIN} -w
      echo "${me} done."
    fi
    ;;
  stop)
    ;;
  *)
    printf "Usage: %s (start)\\n" "$0"
    exit 1
esac

exit 0
