summaryrefslogtreecommitdiff
path: root/pm/sleep.d/90clock
blob: 3adae9883c6818faf65603512716d3d4fd366faa (plain)
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
#!/bin/sh
. /usr/lib/pm-utils/functions

suspend_clock() {
    if [ ! -f /var/run/pm-ntpd.lock ]; then
	touch /var/run/pm-ntpd.lock
    	stopservice ntpd
    fi

    /sbin/hwclock --systohc >/dev/null 2>&1 0<&1
    return $?
}

resume_clock() {
    /sbin/hwclock --hctosys >/dev/null 2>&1 0<&1
    rc=$?

    # Bring back ntpd _after_ NetworkManager and such come back...
    ( touch /var/run/pm-ntpd.lock ;
      sleep 20 ; 
      restartservice ntpd ;
      rm -f /var/run/pm-ntpd.lock
    ) &
    return $rc
}

case "$1" in
	hibernate|suspend)
		suspend_clock
		;;
	thaw|resume)
		resume_clock
		;;
	*)
		;;
esac

exit $?