If you have added your own \boot\grubfm\startup_menu.txt file, you can check for an expiry date. This would force the user to update their USB drive. Here is an example of how to test dates.
Check expiry date
You can add the lines below to check that an expiry date has not been met or exceeded. Change the value of LOWERDATE and UPPERDATE as required to set a valid range.
The code gets the current date in YYYYMMDD format into sdate. The regexp command is used to get the first 8 characters only.
It then compares that dates and reboots the system if the expiry date has been met or if the date is before or equal to the LOWERDATE. The LOWERDATE test helps to prevent the user from cheating by setting the RTC (Real Time Clock) to an earlier date.
This may be of use if you want to force the user to update the USB boot drive after a specific date (.e.g. example = expires Feb 01 - valid for any day in January).
# check date - reset if UPPERDATE (YYYYMMDD) is equal to or smaller than current dateset LOWERDATE=20201231
set UPPERDATE=20210201
unset now;date -s now;regexp -s sdate '(........)' "$now"
# display RTC date and time in human form (optional)
date -m
if [ "${sdate}" -le "${LOWERDATE}" ]; then echo "ERROR: INCORRECT RTC DATE - rebooting..."; sleep 5; reset -w; fi
if [ "${sdate}" -ge "${UPPERDATE}" ]; then echo "ERROR: THIS SOFTWARE HAS EXPIRED ($sdate >= $UPPERDATE) - rebooting..."; sleep 5; reset -w; fi
No comments:
Post a Comment