grub_cmd_set_date.in 774 B

123456789101112131415161718192021222324252627282930313233343536
  1. #! @BUILD_SHEBANG@
  2. set -e
  3. . "@builddir@/grub-core/modinfo.sh"
  4. case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
  5. # FIXME: OpenBIOS on sparc64 doesn't implement RTC
  6. sparc64-ieee1275)
  7. exit 77;;
  8. # PLATFORM: ARC doesn't provide any way to set time
  9. *-arc)
  10. exit 77;;
  11. # PLATFORM: EMU doesn't provide any way to set time
  12. # Even if it did we'd need some kind of sandbox to avoid
  13. # modifying real system time.
  14. *-emu)
  15. exit 77;;
  16. esac
  17. out=$(cat <<EOF | @builddir@/grub-shell
  18. insmod datehook
  19. date
  20. if [ \$YEAR = 2004 -a \$MONTH = 4 -a \$DAY = 4 -a \$HOUR = 20 -a \$MINUTE = 47 ]; then
  21. hello
  22. halt
  23. fi
  24. date 2004-04-04 20:47:00
  25. reboot
  26. EOF
  27. )
  28. if [ "$(echo "$out" | tail -n 1)" != "Hello World" ]; then
  29. echo "Test failed: $out"
  30. exit 1
  31. fi