home *** CD-ROM | disk | FTP | other *** search
/ PCNET 2006 August - Disc 1 / PCNET_CD_2006_08_1.iso / linux / puppy-barebones-2.01r2.iso / pup_201.sfs / usr / sbin / timezone-set < prev    next >
Encoding:
Text File  |  2005-11-02  |  4.2 KB  |  125 lines

  1. #!/bin/sh
  2. #utility to select the timezone. BK 2003, 2005
  3. #Note, as Puppy will mostly be on PCs coexisting with Windows,
  4. #hardware clock (CMOS) is set to local time (see /etc/rc.d/rc.local0)
  5.  
  6. #lrwxrwxrwx 1 root root 28 Aug  5 10:12 localtime -> /usr/share/zoneinfo/GMT+8
  7. TZVAR="`cat /etc/TZ | tr -d "\n"`"
  8. #v1.0.5...
  9. #CZONE="`ls -l /etc/localtime | tr -s ' ' | cut -f 11 -d ' '`"
  10. CZONE="`readlink /etc/localtime`"
  11. CZONE="`basename $CZONE`"
  12. if [ "`echo -n "$CZONE" | grep '\+'`" = "" ];then
  13.  FIXSIGN="`echo -n "$CZONE" | tr "\-" "\+"`"
  14. else
  15.  FIXSIGN="`echo -n "$CZONE" | tr "\+" "\-"`"
  16. fi
  17.  
  18. echo "Click on a button to set Puppy to your timezone" > /tmp/timezones.txt
  19. echo "GMT-10    Alaska, Hawaii" >> /tmp/timezones.txt
  20. echo "GMT-8     Los Angeles" >> /tmp/timezones.txt
  21. echo "GMT-7     Alberta, Montana, Arizona" >> /tmp/timezones.txt
  22. echo "GMT-6     Mexico City, Saskatchewan" >> /tmp/timezones.txt
  23. echo "GMT-5     Bogota, Lima, New York" >> /tmp/timezones.txt
  24. echo "GMT-4     Caracas, La Paz" >> /tmp/timezones.txt
  25. echo "GMT-3     Brasilia, Buenos Aires, Georgetown" >> /tmp/timezones.txt
  26. echo "GMT-1     Azores" >> /tmp/timezones.txt
  27. echo "GMT+0     London, Dublin, Edinburgh, Lisbon, Reykjavik, Casablanca" >> /tmp/timezones.txt
  28. echo "GMT+1     Paris, Berlin, Amsterdam, Brussels, Madrid, Stockholm Oslo" >> /tmp/timezones.txt
  29. echo "GMT+2     Athens, Helsinki, Istanbul, Jerusalem, Harare" >> /tmp/timezones.txt
  30. echo "GMT+3     Kuwait, Nairobi, Riyadh, Moscow" >> /tmp/timezones.txt
  31. echo "GMT+4     Abu Dhabi, Muscat, Tblisi, Volgograd, Kabul" >> /tmp/timezones.txt
  32. echo "GMT+5:30  India" >> /tmp/timezones.txt
  33. echo "GMT+6:30  Cocos Islands" >> /tmp/timezones.txt
  34. echo "GMT+8     Perth, Singapore, Hongkong" >> /tmp/timezones.txt
  35. echo "GMT+9     Tokyo" >> /tmp/timezones.txt
  36. echo "GMT+9:30  Darwin, Adelaide" >> /tmp/timezones.txt
  37. echo "GMT+10    Guam" >> /tmp/timezones.txt
  38. echo "GMT+10:30 Lord Howe Island" >> /tmp/timezones.txt
  39. echo "GMT+12    Wellington, Fiji, Marshall Islands" >> /tmp/timezones.txt
  40. echo "GMT+13    Rawaki Islands" >> /tmp/timezones.txt
  41. echo -n "GMT+14    Line Islands" >> /tmp/timezones.txt
  42.  
  43. BUTTONS='-10:20,-8:18,-7:17,-6:16,-5:15,-4:14,-3:13,-1:11,0:10,+1:21,+2:22,+3:23,+4:24,+5:25,+5╜:41,+6:26,+6╜:42,+7:27,+8:28,+9:29,+9╜:44,+10:30,+10╜:45,+12:32,+13:33,+14:34'
  44.  
  45. xmessage -bg "#ffe0e0" -fg "#ff4040" -center -title "Puppy Timezone Selector. Current timezone: $FIXSIGN" -buttons "$BUTTONS" -file /tmp/timezones.txt
  46. BBB=$?
  47.  
  48. if [ $BBB -le 9 ];then
  49.  exit 0
  50. else
  51. if [ $BBB -le 20 ];then
  52.  TZOFF=`expr $BBB - 10`
  53.  #TZONE="GMT-$TZOFF"
  54.  #TZVAR="UTC-$TZOFF"
  55.  #v1.0.5 change signs...
  56.  TZONE="GMT+$TZOFF"
  57.  TZVAR="PUP$TZOFF" #1st 3 letters do not matter.
  58. else
  59.  if [ $BBB -le 39 ];then
  60.   TZOFF=`expr $BBB - 20`
  61.   #TZONE="GMT+$TZOFF"
  62.   #TZVAR="UTC+$TZOFF"
  63.   #v1.0.5 change signs...
  64.   TZONE="GMT-$TZOFF"
  65.   TZVAR="PUP-$TZOFF" #1st 3 letters do not matter.
  66.  else
  67. #  if [ $BBB -eq 40 ];then #GMT-3:30   
  68. #  else
  69.    if [ $BBB -eq 41 ];then #GMT+5:30
  70.     TZONE="Calcutta"
  71.     #TZVAR="UTC+5:30"
  72.     #v1.0.5 change sign...
  73.     TZVAR="PUP-5:30"
  74.    else
  75.     if [ $BBB -eq 42 ];then #GMT+6:30
  76.      TZONE="Cocos"
  77.      #TZVAR="UTC+6:30"
  78.      #v1.0.5 change sign...
  79.      TZVAR="PUP-6:30"
  80.     else
  81.      if [ $BBB -eq 44 ];then #GMT+9:30
  82.       TZONE="Adelaide"
  83.       #TZVAR="UTC+9:30"
  84.       #v1.0.5 change sign...
  85.       TZVAR="PUP-9:30"
  86.      else
  87.       if [ $BBB -eq 45 ];then #GMT+10:30
  88.        TZONE="Lord_Howe"
  89.        #TZVAR="UTC+10:30"
  90.        #v1.0.5 change sign...
  91.        TZVAR="PUP-10:30"
  92.       else
  93.        exit 0
  94.       fi
  95.      fi
  96.     fi
  97.    fi
  98.   #fi
  99.  fi
  100. fi
  101. fi
  102.  
  103. rm -f /etc/localtime
  104. ln -s /usr/share/zoneinfo/$TZONE /etc/localtime
  105. #not sure, but it may be necessary to also do this...
  106. #rm -f /usr/share/zoneinfo/localtime
  107. #ln -s /usr/share/zoneinfo/$TZONE /usr/share/zoneinfo/localtime
  108. #...no, /usr is readonly f.s.
  109. #also think need to this...
  110. #need to set Linux system time/date, from hardware clock...
  111. /usr/sbin/hwclock --hctosys --localtime
  112. #...--hctosys reads cmos clock to system, referencing 
  113. #   /usr/share/zoneinfo/localtime (link to correct timezone file,
  114. #   that can set by "Set timezone" in Fvwm95 menu).
  115. #...--localtime means that cmos clock is set to local-time.
  116.  
  117. #Hairy nose Puppy (based on uClibc) uses /etc/TZ...
  118. echo "$TZVAR" > /etc/TZ
  119. #...note, file TZ needs a linefeed on end.
  120.  
  121. TZ="$TZVAR"
  122. export TZ
  123.  
  124. ###END###
  125.