Results 1 to 11 of 11

Thread: Time daemons

  1. #1
    Join Date
    Nov 2004
    Posts
    24

    Time daemons

    Here is a compile of openntp (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.

    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
    Last edited by supernaut; 09-10-2007 at 08:50 PM. Reason: Removed old archive

  2. #2
    Join Date
    Nov 2004
    Posts
    24
    Here is a compile of htpdate 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.com
    OR 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.com
    NOTE: 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.
    Last edited by supernaut; 09-10-2007 at 08:51 PM. Reason: Removed old archive

  3. #3
    Join Date
    Nov 2004
    Posts
    24
    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.


    Code:
    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
    Code:
    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)
    Last edited by supernaut; 10-13-2008 at 11:46 AM. Reason: Removed old archive

  4. #4
    Join Date
    Nov 2004
    Posts
    24
    Update htpdate to current.

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

    - Cleanup/simplified the code.
    - Again a more robust implementation of the "-p" (precision) switch.
    Last edited by supernaut; 10-13-2008 at 11:45 AM. Reason: Removed old archive

  5. #5
    Join Date
    May 2007
    Posts
    449
    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.

  6. #6
    Join Date
    Nov 2006
    Posts
    8

    htpdate error

    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?

  7. #7
    Join Date
    Feb 2005
    Posts
    359
    Quote Originally Posted by kakoehler View Post
    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

  8. #8
    Join Date
    Feb 2005
    Posts
    359
    Quote Originally Posted by Soapm View Post
    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.

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

  9. #9
    Join Date
    Nov 2006
    Posts
    8
    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.

  10. #10
    Join Date
    Nov 2004
    Posts
    24
    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.
    Attached Files Attached Files
    Last edited by supernaut; 11-28-2009 at 12:45 PM.

  11. #11
    Join Date
    Nov 2004
    Posts
    24
    Updated htpdate to current (1.0.4) and patched it to use adjtimex (like with openntpd)
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •