home *** CD-ROM | disk | FTP | other *** search
/ chilidog.highland.cc.ks.us / chilidog.highland.cc.ks.us.zip / chilidog.highland.cc.ks.us / backup / bradford.20120305.etc.tar.gz / bradford.20120305.etc.tar / etc / init.d / boot.clock < prev    next >
Text File  |  2006-01-30  |  3KB  |  114 lines

  1. #! /bin/sh
  2. #
  3. # Copyright (c) 2001-2002 SuSE Linux AG, Nuernberg, Germany.
  4. # All rights reserved.
  5. #
  6. # /etc/init.d/boot.clock
  7. #
  8. ### BEGIN INIT INFO
  9. # Provides:          boot.clock
  10. # Required-Start:    boot.localfs
  11. # Required-Stop:
  12. # Default-Start:     B S
  13. # Default-Stop:
  14. # Description:       Read or set hardware clock
  15. ### END INIT INFO
  16.  
  17. . /etc/rc.status
  18. . /etc/sysconfig/clock
  19. rc_reset
  20.  
  21. case "$1" in
  22.     start|restart)
  23.     #
  24.     # Set and adjust the hardware clock
  25.     #    
  26.     if test "$HOSTTYPE" = "s390" -o "$HOSTTYPE" = "s390x" ; then
  27.  
  28.         echo -n Setting up the system clock
  29.  
  30.         # On s390 the hwclock is set outside Linux currently.  The kernel
  31.         # always assumes it to be set to UTC.  So if it is set to local
  32.         # time, we have to compensate for that.  We might achieve this
  33.         # using this special settimeofday(2) linux feature:
  34.         #   Under  Linux there is some peculiar `warp clock' semantics
  35.         #   associated to the settimeofday system call if on the  very
  36.         #   first  call  (after  booting) that has a non-NULL tz argu-
  37.         #   ment, the tv argument is NULL and the tz_minuteswest field
  38.         #   is  nonzero.  In  such  a case it is assumed that the CMOS
  39.         #   clock is on local time, and that it has to be  incremented
  40.         #   by  this  amount to get UTC system time.  No doubt it is a
  41.         #   bad idea to use this feature.  (settimeofday(2) man page)
  42.         # But unless someone complains we simply will use date(1) to shift
  43.         # the system time by the difference between UTC and local time, if
  44.         # the system clock is set to local time.  This will introduce a
  45.         # minimal shift due to the delay between gettimeofday and
  46.         # settimeofday, and it only works as long as $0 is executed
  47.         # exactly once, at boot.
  48.  
  49.         if test "$HWCLOCK" != "-u"; then
  50.         date $(date -u +'%m%d%H%M%Y.%S')
  51.         rc_status
  52.         fi
  53.         #
  54.         # Let zic set timezone - if present.
  55.         #
  56.         if test -n "$TIMEZONE" -a -x /usr/sbin/zic ; then
  57.         echo -n Setting up timezone data
  58.         /usr/sbin/zic -l $TIMEZONE
  59.         rc_status
  60.         fi
  61.  
  62.         rc_status -v -r
  63.     else
  64.  
  65.         echo -n Setting up the hardware clock
  66.  
  67.         if test "$SYSTOHC" = "yes" ; then
  68.         #
  69.         # We write back the system time later at
  70.         # reboot/shutdown time.
  71.         #
  72.         if test ! -f /etc/adjtime ; then
  73.             echo "0.0 0 0"     >  /etc/adjtime
  74.             echo "0"           >> /etc/adjtime
  75.             case "$HWCLOCK" in
  76.             *-u*) echo "UTC"   >> /etc/adjtime ;;
  77.             *-l*) echo "LOCAL" >> /etc/adjtime ;;
  78.             esac
  79.         fi
  80.         /sbin/hwclock --adjust $HWCLOCK
  81.         rc_status
  82.         /sbin/hwclock --hctosys $HWCLOCK
  83.         rc_status
  84.         else
  85.         /sbin/hwclock --hctosys --noadjfile $HWCLOCK
  86.         fi
  87.  
  88.         rc_status -v -r
  89.     fi
  90.     ;;
  91.     stop)
  92.     if test "$HOSTTYPE" != "s390" -a "$HOSTTYPE" != "s390x" ; then
  93.         if test "$SYSTOHC" = "yes" ; then
  94.         echo -n "Set Hardware Clock to the current System Time"
  95.         #
  96.         # Write back to hardware clock and calculate adjtime
  97.         #
  98.         /sbin/hwclock --systohc $HWCLOCK
  99.         rc_status -v -r
  100.         fi
  101.     fi
  102.     ;;
  103.     status)
  104.     rc_failed 4
  105.     rc_status -v
  106.     ;;
  107.     *)
  108.     echo "Usage: $0 {start|stop|status|restart}"
  109.     exit 1
  110.     ;;
  111. esac
  112.  
  113. rc_exit
  114.