US Daylight Savings Time (DST) 2007 Energy Act on Linux

Here is a script to check if your Linux box is ready for the US DST 2007 Energy Act. Save it, chmod it, run it.

#!/bin/bash

status=0

glpackagecheck() {
 rpm=$(rpm -q tzdata)
 case $rpm in
  tzdata-2005m*)
   :
  ;;
  tzdata-2006*)
   :
  ;;
  *)
   echo "RPM tzdata-2005m-1 is not installed. You installed: $rpm"
   status=$(($status+1))
  ;;
 esac
}

glfilecheck() {
 if [ ! -d /usr/share/zoneinfo/America/ ] ; then
  echo "The /usr/share/zoneinfo/America directory does not exist."
  status=$(($status+4))
 fi
}

glfunctioncheck1() {
 storedtz=$(echo $TZ)
 export TZ="America/Adak"
 date | grep 'HA.T' > /dev/null
 if [ $? -gt 0 ] ; then
  echo "Unable to switch timezone."
  status=$(($status+8))
 fi
 export TZ="$storedtz"
}

glfunctioncheck2() {
 zdump -v CST6CDT | grep 2007 | grep "Mar 11" > /dev/null
 if [ $? -gt 0 ] ; then
  echo "Wrong roll over date configured for CST6CDT."
  status=$(($status+16))
 fi
}

glpackagecheck
glfilecheck
glfunctioncheck1
glfunctioncheck2

if [ "$status" -gt 0 ] ; then
 echo "Not all tests ended with success, the status is: $status."
else
 echo "All test successful, you are prepared for the US DST change."
fi
About Consultancy Articles Contact




References Red Hat Certified Architect By Robert de Bock Robert de Bock
Curriculum Vitae By Fred Clausen +31 6 14 39 58 72
By Nelson Manning [email protected]