home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
- #utility to select the timezone. BK 2003, 2005
- #Note, as Puppy will mostly be on PCs coexisting with Windows,
- #hardware clock (CMOS) is set to local time (see /etc/rc.d/rc.local0)
-
- #lrwxrwxrwx 1 root root 28 Aug 5 10:12 localtime -> /usr/share/zoneinfo/GMT+8
- TZVAR="`cat /etc/TZ | tr -d "\n"`"
- #v1.0.5...
- #CZONE="`ls -l /etc/localtime | tr -s ' ' | cut -f 11 -d ' '`"
- CZONE="`readlink /etc/localtime`"
- CZONE="`basename $CZONE`"
- if [ "`echo -n "$CZONE" | grep '\+'`" = "" ];then
- FIXSIGN="`echo -n "$CZONE" | tr "\-" "\+"`"
- else
- FIXSIGN="`echo -n "$CZONE" | tr "\+" "\-"`"
- fi
-
- echo "Click on a button to set Puppy to your timezone" > /tmp/timezones.txt
- echo "GMT-10 Alaska, Hawaii" >> /tmp/timezones.txt
- echo "GMT-8 Los Angeles" >> /tmp/timezones.txt
- echo "GMT-7 Alberta, Montana, Arizona" >> /tmp/timezones.txt
- echo "GMT-6 Mexico City, Saskatchewan" >> /tmp/timezones.txt
- echo "GMT-5 Bogota, Lima, New York" >> /tmp/timezones.txt
- echo "GMT-4 Caracas, La Paz" >> /tmp/timezones.txt
- echo "GMT-3 Brasilia, Buenos Aires, Georgetown" >> /tmp/timezones.txt
- echo "GMT-1 Azores" >> /tmp/timezones.txt
- echo "GMT+0 London, Dublin, Edinburgh, Lisbon, Reykjavik, Casablanca" >> /tmp/timezones.txt
- echo "GMT+1 Paris, Berlin, Amsterdam, Brussels, Madrid, Stockholm Oslo" >> /tmp/timezones.txt
- echo "GMT+2 Athens, Helsinki, Istanbul, Jerusalem, Harare" >> /tmp/timezones.txt
- echo "GMT+3 Kuwait, Nairobi, Riyadh, Moscow" >> /tmp/timezones.txt
- echo "GMT+4 Abu Dhabi, Muscat, Tblisi, Volgograd, Kabul" >> /tmp/timezones.txt
- echo "GMT+5:30 India" >> /tmp/timezones.txt
- echo "GMT+6:30 Cocos Islands" >> /tmp/timezones.txt
- echo "GMT+8 Perth, Singapore, Hongkong" >> /tmp/timezones.txt
- echo "GMT+9 Tokyo" >> /tmp/timezones.txt
- echo "GMT+9:30 Darwin, Adelaide" >> /tmp/timezones.txt
- echo "GMT+10 Guam" >> /tmp/timezones.txt
- echo "GMT+10:30 Lord Howe Island" >> /tmp/timezones.txt
- echo "GMT+12 Wellington, Fiji, Marshall Islands" >> /tmp/timezones.txt
- echo "GMT+13 Rawaki Islands" >> /tmp/timezones.txt
- echo -n "GMT+14 Line Islands" >> /tmp/timezones.txt
-
- 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'
-
- xmessage -bg "#ffe0e0" -fg "#ff4040" -center -title "Puppy Timezone Selector. Current timezone: $FIXSIGN" -buttons "$BUTTONS" -file /tmp/timezones.txt
- BBB=$?
-
- if [ $BBB -le 9 ];then
- exit 0
- else
- if [ $BBB -le 20 ];then
- TZOFF=`expr $BBB - 10`
- #TZONE="GMT-$TZOFF"
- #TZVAR="UTC-$TZOFF"
- #v1.0.5 change signs...
- TZONE="GMT+$TZOFF"
- TZVAR="PUP$TZOFF" #1st 3 letters do not matter.
- else
- if [ $BBB -le 39 ];then
- TZOFF=`expr $BBB - 20`
- #TZONE="GMT+$TZOFF"
- #TZVAR="UTC+$TZOFF"
- #v1.0.5 change signs...
- TZONE="GMT-$TZOFF"
- TZVAR="PUP-$TZOFF" #1st 3 letters do not matter.
- else
- # if [ $BBB -eq 40 ];then #GMT-3:30
- # else
- if [ $BBB -eq 41 ];then #GMT+5:30
- TZONE="Calcutta"
- #TZVAR="UTC+5:30"
- #v1.0.5 change sign...
- TZVAR="PUP-5:30"
- else
- if [ $BBB -eq 42 ];then #GMT+6:30
- TZONE="Cocos"
- #TZVAR="UTC+6:30"
- #v1.0.5 change sign...
- TZVAR="PUP-6:30"
- else
- if [ $BBB -eq 44 ];then #GMT+9:30
- TZONE="Adelaide"
- #TZVAR="UTC+9:30"
- #v1.0.5 change sign...
- TZVAR="PUP-9:30"
- else
- if [ $BBB -eq 45 ];then #GMT+10:30
- TZONE="Lord_Howe"
- #TZVAR="UTC+10:30"
- #v1.0.5 change sign...
- TZVAR="PUP-10:30"
- else
- exit 0
- fi
- fi
- fi
- fi
- #fi
- fi
- fi
- fi
-
- rm -f /etc/localtime
- ln -s /usr/share/zoneinfo/$TZONE /etc/localtime
- #not sure, but it may be necessary to also do this...
- #rm -f /usr/share/zoneinfo/localtime
- #ln -s /usr/share/zoneinfo/$TZONE /usr/share/zoneinfo/localtime
- #...no, /usr is readonly f.s.
- #also think need to this...
- #need to set Linux system time/date, from hardware clock...
- /usr/sbin/hwclock --hctosys --localtime
- #...--hctosys reads cmos clock to system, referencing
- # /usr/share/zoneinfo/localtime (link to correct timezone file,
- # that can set by "Set timezone" in Fvwm95 menu).
- #...--localtime means that cmos clock is set to local-time.
-
- #Hairy nose Puppy (based on uClibc) uses /etc/TZ...
- echo "$TZVAR" > /etc/TZ
- #...note, file TZ needs a linefeed on end.
-
- TZ="$TZVAR"
- export TZ
-
- ###END###
-