PDA

View Full Version : Time daemons



supernaut
02-26-2006, 01:35 PM
Here is a compile of openntp (http://www.openntpd.org/) (3.7p1) for mips TiVo. Openntp is a daemon that can be used to sync your TiVo's time to other time servers. It can also act as a time server itself. The manual is here (http://www.openntpd.org/manual.html).

You can set up openntp on your TiVo as follows:

1. transfer openntp.zip to your TiVo and expand to /var/hack.
2. mkdir -p /tivo-bin/ntp
3. chmod 755 ntpd
4. mv ntpd /tivo-bin/.
5. mv ntpd.conf /tivo-bin/ntp/.
6. add "ntp:x:50:50:ntp:/var/tmp/ntp:/tivo-bin/false" (no quotes) to /etc/passwd.
7. add "ntp:x:50:" to /etc/group
8. echo -e '#!/bin/sh\nexit 1' > /tivo-bin/false
9. chmod 755 /tivo-bin/false
10. mkdir -p /var/tmp/ntp
11. Take a look at /tivo-bin/ntp/ntpd.conf:
# $OpenBSD: ntpd.conf,v 1.7 2004/07/20 17:38:35 henning Exp $
# sample ntpd configuration file, see ntpd.conf(5)

# Addresses to listen on (ntpd does not listen by default)
#listen on *
#listen on 127.0.0.1
#listen on ::1

# sync to a single server
#server ntp.example.org
server 0.north-america.pool.ntp.org
server 1.north-america.pool.ntp.org
server 2.north-america.pool.ntp.org

# use a random selection of 8 public stratum 2 servers
# see http://twiki.ntp.org/bin/view/Servers/NTPPoolServers
#servers north-america.pool.ntp.org
In this configuration, ntpd will sync with three random ntp servers localized to North America. It is NOT listening for sync requests. See the manual for other configurations.
12. start the daemon using "/tivo-bin/ntpd -s -d -f /tivo-bin/ntp/ntpd.conf" and check that it works.
13. if everything looks good, then you can launch it from rc.sysinit.author using:
#Start ntpd
[ ! -d /var/tmp/ntp ] && mkdir -p /var/tmp/ntp
/tivo-bin/ntpd -s -f /tivo-bin/ntp/ntpd.conf &
14. mv /bin/ntpdate /bin/ntpdate.orig
15. I have replaced /bin/ntpdate with this shell script (Note: touch is from busybox):

#!/bin/sh
#
(
/tivo-bin/touch /var/timestamp &&
/sbin/syslog -t ntpdate "TiVo call-in detected - touched timestamp"
)
exit 0
This just keeps "timestamp" in sync with each call in, and writes successes to /var/log/messages.

16. chmod 755 /bin/ntpdate

supernaut
02-26-2006, 02:11 PM
Here is a compile of htpdate (http://www.clevervest.com/htp/intro.html) for mips TiVo. htpdate allows you to sync your TiVo's clock even when either your firewall or your ISP has problems passing UDP traffic back to your TiVo (i.e., ntp reply traffic from a time server is blocked).
htpdate version 0.9.0
Usage: htpdate [-046adhlqstD] [-i pid file] [-m minpoll] [-M maxpoll]
[-p precision] [-P [: port]] ...

-0 HTTP/1.0 request
-4 Force IPv4 name resolution only
-6 Force IPv6 name resolution only
-a adjust time smoothly
-d debug mode
-D daemon mode
-h help
-i pid file
-l use syslog for output
-m minimum poll interval
-M maximum poll interval
-p precision (ms)
-P proxy server
-q query only, don't make time changes (default)
-s set time
-t turn off sanity time check
host web server hostname or ip address (maximum of 16)
port port number (default 80 and 8080 for proxy server)You can set up openntp on your TiVo as follows:

1. transfer htpdate.zip to your TiVo and expand to /var/hack.
2. cp htpdate /tivo-bin/.
3. chmod 755 /tivo-bin/htpdate

You can use htpdate like ntpdate and run it once to sync your time:
/tivo-bin/htpdate -4 -s -t www.google.com www.yahoo.comOR you can run it as a daemon called from rc.sysinit.author:
# Start htpdate
/tivo-bin/htpdate -4 -l -s -t -D www.google.com www.yahoo.comNOTE: www.google.com and www.yahoo.com are just examples. Use your best judgement for which www servers to use. Also, if you want to test a time sync to a new www server without changing your clock (which is always a good idea!), you can use:
/tivo-bin/htpdate -4 -q -d www.google.com
Lastly, you can rename ntpdate to ntpdate.orig and replace it with the shell script above (openntp 14,15, and 16) to keep /var/timestamp in sync.

supernaut
01-13-2007, 07:37 PM
New versions of openntpd and htpdate. Old versions of each program have been running on each of my TiVos for over a year now as daemons, keeping perfect time. Setup is as described in the previous two posts.



Network Time Protocol daemon 3.9.1p1 for mips TiVo

usage: ntpd [-dhSs] [-f file]
-d Do not daemonize
-f file Use file as the configuration file
-h Help
-S Do not set the time immediately at startup
-s Set the time immediately at startup if the local clock is off
by more than 180 seconds




htpdate version 0.9.3 for mips TiVo
Usage: htpdate [-046adhlqstxD] [-i pid file] [-m minpoll] [-M maxpoll]
[-p precision] [-P <proxyserver>[:port]] [-u user[:group]]
<host[:port]> ...

-0 HTTP/1.0 request
-4 Force IPv4 name resolution only
-6 Force IPv6 name resolution only
-a adjust time smoothly
-d debug mode
-D daemon mode
-h help
-i pid file
-l use syslog for output
-m minimum poll interval
-M maximum poll interval
-p precision (ms)
-P proxy server
-q query only, don't make time changes (default)
-s set time
-t turn off sanity time check
-u run daemon as user
-x adjust kernel clock
host web server hostname or ip address (maximum of 16)
port port number (default 80 and 8080 for proxy server)

supernaut
09-14-2007, 11:48 PM
Update htpdate to current.


Changes in 1.0.0
----------------

- Cleanup/simplified the code.
- Again a more robust implementation of the "-p" (precision) switch.

Soapm
09-15-2007, 12:10 AM
Does anyone know if Comcast has a time server. My Tivo runs about 2 minutes ahead of my cable box. I would like to have this run to Comcast time server to keep them both the same.

kakoehler
10-21-2007, 04:53 PM
I'm trying to use htpdate and it wont work unless I supply an IP address as opposed to www.google.com. It comes back with an error of can't resolve the name. I've put in various DNS server names in the Tivo and no change to htpdate.
wget works with both IP addresses and www.google.com.

Anyone have any ideas why my htpdate doesn't work?

ocntscha
10-21-2007, 09:04 PM
Anyone have any ideas why my htpdate doesn't work?

Maybe you are putting http:// in front of the remote server? If you are, don't.

This works:

htpdate www.google.com

This doesn't:

htpdate http://www.google.com

ocntscha
10-21-2007, 09:15 PM
Does anyone know if Comcast has a time server. My Tivo runs about 2 minutes ahead of my cable box. I would like to have this run to Comcast time server to keep them both the same.
You may be interested in this (http://dealdatabase.com/forum/showthread.php?p=271498#post271498).

I'ts been working perfectly for me ever since last December when I made it. You could set SKEW_AMOUNT='-120'

kakoehler
10-22-2007, 08:28 AM
I've tried htpdate both ways. With and without http:// and it doesn't work unless I put in the actual IP address. It must be associated with DNS somehow. That's why I tried wget to see if it would work using DNS and it worked fine. The TIVO box I am using is hacked and not subbed. My TIVO software system is 4.0.1b-02-2-240 and maybe that's the problem.

supernaut
10-13-2008, 12:44 PM
Here is the latest for htpdate (1.0.3).

Added "-b" Burst mode uses multiple polls for each web server to enhance accuracy

Also, here is a patched version of the openntp (3.9.3p1).

This patch (by Darren Tucker) forces use of adjtimex calls (unique to Linux) to deal with systematic clock drift. The unpatched version uses the portable (but less robust) adjtime. Also changed the immediate set clock threshold to 10s.

supernaut
11-28-2009, 01:47 PM
Updated htpdate to current (1.0.4) and patched it to use adjtimex (like with openntpd)