Slackware 11.0 - NTP
====================

Public domain    
********************************************************************************
### Timezone update
    
    # cd /usr/src/
    # mkdir timezones
    # cd timezones/
    # wget ftp://elsie.nci.nih.gov/pub/tzdata2008a.tar.gz
    # tar -xzvf tzdata2008a.tar.gz
    # zic -d zoneinfo asia
    # cd zoneinfo/
    # /usr/bin/cp -r * /usr/share/zoneinfo/
    # /usr/bin/cp /usr/share/zoneinfo/Asia/Tehran /etc/localtime
    # ln -sfn /usr/share/zoneinfo/Asia/Tehran /etc/localtime-copied-from
    # /usr/sbin/ntpdate -s -b -p 8 0.pool.ntp.org 1.pool.ntp.org 2.pool.ntp.org
    
********************************************************************************
### /etc/ntp.conf
    
    server 0.pool.ntp.org
    restrict 0.pool.ntp.org
    server 1.pool.ntp.org
    restrict 1.pool.ntp.org
    server 2.pool.ntp.org
    restrict 2.pool.ntp.org
    server  127.127.1.0     # local clock
    fudge   127.127.1.0 stratum 10
    driftfile /etc/ntp/drift
    restrict default ignore
    restrict 127.0.0.0 mask 255.0.0.0
    authenticate no
    
********************************************************************************
### /etc/ntp/step-tickers
    
    0.pool.ntp.org
    1.pool.ntp.org
    2.pool.ntp.org
    
********************************************************************************
### /etc/rc.d/rc.ntpd
    
    #!/bin/sh
    #
    # /etc/rc.d/rc.ntpd
    #
    # Start/stop/restart the ntp daemon
    #
    # To make this service start automatically at boot, make this
    # file executable:  chmod 755 /etc/rc.d/rc.ntpd
    #
    
    start ()
    {
      echo "Setting clock from a public ntp servers..."
      /usr/sbin/ntpdate -s -b -p 8 0.pool.ntp.org 1.pool.ntp.org 2.pool.ntp.org
      sleep 2
    
      echo "Setting hardware clock..."
      /sbin/hwclock -w
    
      echo "Starting Network Time Protocol daemon..."
      /usr/sbin/ntpd -l /tmp/ntp.log
    }
    
    stop ()
    {
      echo "Stopping Network Time Protocol daemon..."
      pid=$(  /bin/ps -e |\
              /usr/bin/grep ' ntpd' |\
              /usr/bin/sed -e 's,^ *,,' -e 's, .*,,'  )
      if [ "${pid}" != '' ]; then
        kill ${pid}
      fi
    }
    
    case "$1" in
      'start')
        start
        ;;
      'stop')
        stop
        ;;
      'restart')
        stop
        sleep 1
        start
        ;;
      *)
        echo "usage $0 start|stop|restart" ;;
    esac
    
********************************************************************************
### /etc/rc.d/rc.local
    
    # Start the NTP daemon
    #
    if [ -x /etc/rc.d/rc.ntpd ]
     then
      /etc/rc.d/rc.ntpd start
    fi
    
********************************************************************************
### First time start
    
    # chmod 755 /etc/rc.d/rc.ntpd
    # /usr/sbin/ntpdate -s -b -p 8 0.pool.ntp.org 1.pool.ntp.org 2.pool.ntp.org
    # /sbin/hwclock -w
    # /etc/rc.d/rc.ntpd start
    
    
********************************************************************************
_BY: Pejman Moghadam_  
_TAG: ntp_  
_DATE: 2008-03-21 08:12:01_