~ubuntu-branches/ubuntu/natty/sadms/natty

« back to all changes in this revision

Viewing changes to bin/_sync-clocks.sh

  • Committer: Bazaar Package Importer
  • Author(s): Gauvain Pocentek
  • Date: 2010-02-22 20:14:54 UTC
  • Revision ID: james.westby@ubuntu.com-20100222201454-up4zkzo13w9091i0
Tags: upstream-2.0.14~CVS20100222
ImportĀ upstreamĀ versionĀ 2.0.14~CVS20100222

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash
 
2
# bbou@ac-toulouse.fr
 
3
# 2007-05-22 16:29:48 
 
4
# _sync-clocks.sh
 
5
 
 
6
### P A R A M S
 
7
 
 
8
MYSERVER="$1"
 
9
 
 
10
### S T A R T
 
11
 
 
12
# this doesn't seem to work properly
 
13
function setnettime0()
 
14
{
 
15
net time set $1 > /dev/null
 
16
}
 
17
 
 
18
function setnettime()
 
19
{
 
20
if ! net time system $1 > /dev/null; then
 
21
        return 1
 
22
fi
 
23
t=`net time system $1`
 
24
date $t > /dev/null
 
25
}
 
26
 
 
27
echo "--------------------------------------------------------------------------------"
 
28
echo "SYNCHRONIZING CLOCKS WITH ${MYSERVER}"
 
29
echo "--------------------------------------------------------------------------------"
 
30
 
 
31
serveropt=""
 
32
if [ "${MYSERVER}" != "" ]; then
 
33
        serveropt="-S ${MYSERVER}"
 
34
fi
 
35
echo "+synchronizing clocks"
 
36
if setnettime "${serveropt}" > /dev/null; then
 
37
nettime=`net time ${serveropt} | sed 's/\n//g'`
 
38
echo -n "net time is now:       "
 
39
date -d "${nettime}" "+%Y-%m-%d %H:%M.%S"
 
40
fi
 
41
 
 
42
echo -n "local time is now:     "
 
43
date "+%Y-%m-%d %H:%M.%S"