#!/bin/bash
# AQ
# 20141020

offset=`date +%:::z | sed "s/+0//g;s/+//g"`
if [ -z $1 ]; then
    let "offset = offset - 1"
    cp -f /usr/share/zoneinfo/Etc/GMT-$offset /etc/localtime
    if [ $? -ne 0 ]; then
        echo "Error"
        exit 1
    fi
    echo "TZFIX set zone $offset" >> log/add/start.log
else
    cp -f /usr/share/zoneinfo/Etc/GMT-$1 /etc/localtime
    if [ $? -ne 0 ]; then
        echo "Error"
        exit 1
    fi
    echo "TZFIX set zone $1" >> log/add/start.log
fi

if [ -f tzupdater.jar ]; then
    java -jar tzupdater.jar -u
fi
