#!/bin/bash # Tests whether the hibernation file on the specified FAT filesystem is inactive # or currently contains a hibernated Windows system # # Based on guesswork about hiberfil.sys format: may not work correctly! # # Seb Wills 2005 # Improvements to saw27@mrao.cam.ac.uk # Prints message and exits with status 0 if inactive, 1 if active, 2 if error. mountpoint=/mnt/c device=/dev/hda1 if ! ( mountpoint -q $mountpoint ) ; then # not mounted already if ! ( mount -t vfat -o ro $device $mountpoint ) ; then echo "Failed to mount $mountpoint readonly"; exit 2; fi we_mounted=1; fi if ( head -c 4 $mountpoint/hiberfil.sys | grep -q hibr ) ; then echo "Windows is hibernating!"; result=1; else echo "Hibernation file is inactive"; result=0; fi if [ $we_mounted ]; then umount $mountpoint fi exit $result;