1
0
mirror of https://github.com/myvesta/vesta.git synced 2025-03-11 03:52:44 -07:00
myvesta/bin/v-get-sys-timezone

50 lines
1.3 KiB
Plaintext
Raw Normal View History

2015-01-11 20:35:46 +02:00
#!/bin/bash
# info: get system timezone
# options: [FORMAT]
#
# The function to get system timezone
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
2015-11-06 17:38:58 +02:00
# Argument definition
2015-01-11 20:35:46 +02:00
format=${1-shell}
# Includes
source $VESTA/func/main.sh
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Checking timesonze on RHEL/CentOS
if [ -f "/etc/sysconfig/clock" ]; then
source /etc/sysconfig/clock
# Checking timezone on Debian/Ubuntu
elif [ -f "/etc/timezone" ]; then
ZONE=$(cat /etc/timezone)
# Checking symlynks
elif [ -h /etc/localtime ]; then
2015-05-29 01:50:40 +03:00
ZONE=$(readlink /etc/localtime | sed "s%.*share/zoneinfo/%%")
2015-01-11 20:35:46 +02:00
# Parsing zoneinfo (very slow)
else
checksum=$(md5sum /etc/localtime | cut -d' ' -f1)
ZONE=$(find /usr/share/zoneinfo/ -type f -exec md5sum {} \; |\
grep "^$checksum" | sed "s/.*\/usr\/share\/zoneinfo\///" | head -n 1)
fi
echo $ZONE
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
exit