#!/bin/bash
:<<COMMENT
Author:huangyandong
Date:11/13/11 release 1.0
Web:http://huangyandong.blog.51cto.com
RunAs:root
COMMENT
PS3="选择操作:"
select doing in "设置时区" "设置日期" "设置时间" "显示当前时间和日期" "退出
do
if [ x$doing == "x设置时区" ];then
zone=$(tzselect)
echo "你要设置的时区为$zone,确定(y)"
read isdo
case $isdo in
    y|Y)  cp -v /usr/share/zoneinfo/${zone} /etc/localtime ;;
esac
fi
if [ x$doing == "x设置日期" ];then
read -p "输入要设置的日期(YYYY-MM-DD)" sdate
echo "你要设置的日期为$sdate,确定(y)"
read isdo
case $isdo in
    y|Y) date +%D -s "$sdate" ;;
esac
fi
if [ x$doing == "x设置时间" ];then
read -p "输入要设置的时间(HH:MM:SS)" stime
read -p "是否使用UTC时间,(y)" sutc 
case $sutc in
    y|Y) msg="使用UTC时间";utc='-u';;
esac
echo "你要$msg设置的时间为$stime,确定(y)"
read isdo
case $isdo in
    y|Y) date +%T -s "$stime" $utc ;;
esac
fi
if [ x$doing == "x显示当前时间和日期" ];then
date
fi
if [ x$doing == "x退出" ];then
exit 0;
fi
done