1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
|
# -*- sh -*-
# vim:ft=sh:ts=8:sw=4:noet
AddConfigHandler ClockOptions
AddConfigHelp "SaveClock restore-only|<boolean>" "Set this to yes to save the system clock before suspending and restore the system clock after resuming. If set to restore-only, the clock will not be saved, only restored - this means suspending is faster, but if your hardware clock drifts significantly, your system clock will drift as well."
ClockSave() {
case "$DISTRIBUTION" in
debian|ubuntu)
/etc/init.d/hwclock.sh stop > /dev/null 2>&1
;;
gentoo)
/etc/init.d/clock.sh stop > /dev/null 2>&1
;;
*)
if ! /sbin/hwclock $DIRECTISA --systohc ; then
echo "$EXE: Failed to save system clock - continuing anyway"
fi
;;
esac
return 0 # clock save failing shouldn't be a show stopper, ever.
}
ClockRestore() {
case "$DISTRIBUTION" in
debian|ubuntu)
/etc/init.d/hwclock.sh start > /dev/null 2>&1
;;
gentoo)
/etc/init.d/clock.sh start > /dev/null 2>&1
;;
*)
if ! /sbin/hwclock $DIRECTISA --hctosys ; then
echo "$EXE: Failed to restore system clock."
fi
;;
esac
# exit code unchanged.
}
ClockOptions() {
local param
case $1 in
directisa)
case "$DISTRIBUTION" in
gentoo)
echo "$EXE: Options for hwclock should be set in /etc/init.d/clock.sh"
exit 1
;;
debian|ubuntu)
echo "$EXE: Options for hwclock should be set in /etc/init.d/hwclock.sh"
exit 1
;;
*)
DIRECTISA="--directisa"
;;
esac
;;
saveclock)
param=`echo $2 | tr '[A-Z]' '[a-z]'`
case "$param" in
restore*) # restore-only
AddResumeHook 70 ClockRestore
;;
*)
if BoolIsOn "$1" "$2" ; then
# put before module unloading and x switching.
AddSuspendHook 70 ClockSave
AddResumeHook 70 ClockRestore
fi
;;
esac
;;
*)
return 1
esac
return 0
}
# $Id$
|