summaryrefslogtreecommitdiffstats
path: root/meta-oe/recipes-support/ntp/files/ntpdate
diff options
context:
space:
mode:
Diffstat (limited to 'meta-oe/recipes-support/ntp/files/ntpdate')
-rwxr-xr-xmeta-oe/recipes-support/ntp/files/ntpdate49
1 files changed, 49 insertions, 0 deletions
diff --git a/meta-oe/recipes-support/ntp/files/ntpdate b/meta-oe/recipes-support/ntp/files/ntpdate
new file mode 100755
index 0000000000..784b029ad5
--- /dev/null
+++ b/meta-oe/recipes-support/ntp/files/ntpdate
@@ -0,0 +1,49 @@
1#!/bin/sh
2
3PATH=/sbin:/bin:/usr/bin
4
5test -x /usr/bin/ntpdate || exit 0
6
7if test -f /etc/default/ntpdate ; then
8. /etc/default/ntpdate
9else
10NTPSERVERS="pool.ntp.org"
11fi
12
13test -n "$NTPSERVERS" || exit 0
14
15# This is a heuristic: The idea is that if a static interface is brought
16# up, that is a major event, and we can put in some extra effort to fix
17# the system time. Feel free to change this, especially if you regularly
18# bring up new network interfaces.
19if [ "$METHOD" = static ]; then
20 OPTS="-b"
21fi
22
23if [ "$METHOD" = loopback ]; then
24 exit 0
25fi
26
27(
28
29LOCKFILE=/var/lock/ntpdate
30
31# Avoid running more than one at a time
32if [ -x /usr/bin/lockfile-create ]; then
33 lockfile-create $LOCKFILE
34 lockfile-touch $LOCKFILE &
35 LOCKTOUCHPID="$!"
36fi
37
38if /usr/bin/ntpdate -s $OPTS $NTPSERVERS 2>/dev/null; then
39 if [ "$UPDATE_HWCLOCK" = "yes" ]; then
40 hwclock --systohc || :
41 fi
42fi
43
44if [ -x /usr/bin/lockfile-create ] ; then
45 kill $LOCKTOUCHPID
46 lockfile-remove $LOCKFILE
47fi
48
49) &