#!/bin/bash

# Script to read the time zone per L3090.
#
# The main objective is to pass back the Linux Operating System TimeZone
# to the Java code because the Java's TimeZone can be different due to
# the /opt/ibm/java2-i386-50/jre/lib/tzmappings file.
#
# Module History:
# 00 09/21/2007  J. Bieber     D73A L3090 Base code release

actzTrace "XTODRTZT: -> readTimeZone"

localTimeFile='/etc/localtime'
# logFile='/console/data/readTimeZoneLog'

# Save this file in case we need to retrieve this file.
# echo "`date` Checking if $timeZoneDir is a symbolic link." >> $logFile

# Let's perform a list of the localTimeFile and save it in our log file.
# ls -l $localTimeFile >> $logFile

# Let's test to see if we have a symbolic link
if [ -L $localTimeFile ]; then
 find $localTimeFile -type l -printf \"%l:\"
 findRC = $?
 if [ $findRC -eq 0 ]; then
   # Arbritary, unique success code
   actzTrace "XTODRTZF: <- readTimeZone Return code 50"
   exit 50
 else
   # we got exactly what we wanted.  Let's return it.
   actzTrace "XTODRTZF: <- readTimeZone Returning $findRC"
   exit $findRC
 fi
elif [ -f $localTimeFile ]; then
  # This is not a symbolically linked file (e.g. a copy of /usr/share/zoneinfo/*)
  sum $localTimeFile
  sumRC=$?
  if [ $sumRC -eq 0 ]; then
    # Arbritary, unique success code
    actzTrace "XTODRTZF: <- readTimeZone Return code 51"
    exit 51
  else
    # Pass back the checksum of the time zone file.
    actzTrace "XTODRTZF: <- readTimeZone Returning checksum $sumRC"
    exit $sumRC
  fi
else
  # Pass back an non-zero error code.
  actzTrace "XTODRTZF: <- readTimeZone Return code 1"
  exit 1;
fi
