/
v-get-sys-timezones
executable file
·61 lines (50 loc) · 1.36 KB
/
v-get-sys-timezones
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
# info: list system timezone
# options: [FORMAT]
#
# example: v-get-sys-timezones json
#
# This function checks system timezone settings
#----------------------------------------------------------#
# Variables & Functions #
#----------------------------------------------------------#
# Argument definition
format=${1-shell}
# Includes
# shellcheck source=/etc/hestiacp/hestia.conf
source /etc/hestiacp/hestia.conf
# shellcheck source=/usr/local/hestia/func/main.sh
source $HESTIA/func/main.sh
# load config file
source_conf "$HESTIA/conf/hestia.conf"
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
json_list() {
jq -ncR '[inputs]' <<< "$zones"
}
shell_list() {
IFS=$'\n'
echo "Timezone"
echo "--------"
for zone in $zones; do
echo $zone
done
}
plain_list() {
IFS=$'\n'
for zone in $zones; do
echo $zone
done
}
zones=$(cd /usr/share/zoneinfo/posix && find -L * -type f -or -type l | sort)
# Listing data
case $format in
json) json_list ;;
plain) plain_list ;;
shell) shell_list | column -t ;;
esac
#----------------------------------------------------------#
# Hestia #
#----------------------------------------------------------#
exit