Mt Xia: Technical Consulting Group

Business Continuity / Disaster Recovery / High Availability
Data Center Automation / Audit Response / Audit Compliance

-
Current Location
-

css
  GlobalSysAdmin
    Power5

-

digg Digg this page
del.icio.us Post to del.icio.us
Slashdot Slashdot it!


Business Web Site Hosting
$3.99 / month includes Tools,
Shopping Cart, Site Builder

www.siteox.com

FREE Domain Registration
included with Web Site Hosting
Tools, Social Networking, Blog

www.siteox.com


#!/usr/bin/ksh93.att
################################################################
#### 
#### Description: Script to change the time zone variable (TZ) in
#### the /etc/environment file.  The TZ variable is modified to
#### reflect the new DST changes.
#### 
#### Central US 	TZ=CST6CDT,M3.2.0,M11.1.0
#### 
################################################################
function mkversion {
  typeset FNAME
  typeset F

  FNAME="${1:?ERROR: Syntax \"${0} fileName\"}"
  [[ ! -f ${FNAME} ]] && echo "ERROR: ${FNAME} does not exist" && return 1

  for F in $( ls -1r ${FNAME}.+([0-9]) 2>/dev/null )
  do
    [[ ! -w ${F} ]] && echo "ERROR: ${F} is not writeable" && return 2
    [[ ! -r ${F} ]] && echo "ERROR: ${F} is not readable" && return 3
    [[ ! -w ${F%/*} ]] && echo "ERROR: . is not writeable" && return 4
  done
  for F in $( ls -1r ${FNAME}.+([0-9]) 2>/dev/null )
  do
    cp -f ${F} ${FNAME}.$(( ${F#${FNAME}.} + 1 )) || return 5
  done
  cp -f "${FNAME}" "${FNAME}.0"
}
################################################################
function chenv {
  typeset ENVFILE="/etc/environment"
  typeset ENVFILE="./environment"
  typeset TMPFILE="/tmp/environment.${$}.tmp"
  typeset VARNAME="TZ"
  typeset OLDVAL="CST6CDT"
  typeset NEWVAL="${OLDVAL},M3.2.0,M11.1.0"

  if [[ ! -w "${ENVFILE}" ]]
  then
    print -u 2 -- "# ERROR: ${ENVFILE} is not writable by this user"
    exit 1
  fi

  print -- "# current ${ENVFILE} ${VARNAME} variable is defined as follows:"
  grep "^${VARNAME}=" "${ENVFILE}"

  mkversion "${ENVFILE}"

  exec 3<"${ENVFILE}"
  exec 4>"${TMPFILE}"
  while IFS="" read -u 3 -r -- LINE
  do
      if [[ "_${LINE}" == _${VARNAME}=${OLDVAL}* ]]
      then
          print -u 4 -- "${VARNAME}=${NEWVAL}"
      else
          print -u 4 -r -- "${LINE}"
      fi
  done
  exec 3<&-
  exec 4>&-

  if cp -f "${TMPFILE}" "${ENVFILE}"
  then
    print -- "# successfully modified ${ENVFILE} ${VARNAME} variable as follows:"
    grep "^${VARNAME}=" "${ENVFILE}"
  else
    print -- "# ERROR: unable to modify ${ENVFILE}"
  fi

  rm -f "${TMPFILE}"
  return 0
}
################################################################

chenv "${@}"

-
DST TZ Modification Script
-
 

DST Updates at MDC
DST Updates at DDC


FREE Domain Registration
included with Web Site Hosting
Tools, Social Networking, Blog

www.siteox.com

Business Web Site Hosting
$3.99 / month includes Tools,
Shopping Cart, Site Builder

www.siteox.com