File tree Expand file tree Collapse file tree 2 files changed +525
-0
lines changed
Expand file tree Collapse file tree 2 files changed +525
-0
lines changed Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ # info: get system timezone
3+ # options: [FORMAT]
4+ #
5+ # The function to get system timezone
6+
7+
8+ # ----------------------------------------------------------#
9+ # Variable&Function #
10+ # ----------------------------------------------------------#
11+
12+ # Argument defenition
13+ format=${1-shell}
14+
15+ # Includes
16+ source $VESTA /func/main.sh
17+
18+
19+ # ----------------------------------------------------------#
20+ # Action #
21+ # ----------------------------------------------------------#
22+
23+ # Checking timesonze on RHEL/CentOS
24+ if [ -f " /etc/sysconfig/clock" ]; then
25+ source /etc/sysconfig/clock
26+
27+ # Checking timezone on Debian/Ubuntu
28+ elif [ -f " /etc/timezone" ]; then
29+ ZONE=$( cat /etc/timezone)
30+
31+ # Checking symlynks
32+ elif [ -h /etc/localtime ]; then
33+ ZONE=$( readlink /etc/localtime | sed " s/\/usr\/share\/zoneinfo\///" )
34+
35+ # Parsing zoneinfo (very slow)
36+ else
37+ checksum=$( md5sum /etc/localtime | cut -d' ' -f1)
38+ ZONE=$( find /usr/share/zoneinfo/ -type f -exec md5sum {} \; | \
39+ grep " ^$checksum " | sed " s/.*\/usr\/share\/zoneinfo\///" | head -n 1)
40+ fi
41+
42+ echo $ZONE
43+
44+
45+ # ----------------------------------------------------------#
46+ # Vesta #
47+ # ----------------------------------------------------------#
48+
49+ exit
You can’t perform that action at this time.
0 commit comments