1
0
mirror of https://github.com/EliasKotlyar/Xiaomi-Dafang-Hacks.git synced 2025-09-09 15:40:45 +02:00

timezone selector fix (#909)

* Added time zone selection in web config based on time zone name.

* Added default timezone config file. Default is Abidjan because first in list that is GMT0, which probably matches the default in `/etc/TZ`

* Update timezone.conf

* Added default timezone config file. Default is Abidjan because first in list that is GMT0, which probably matches the default in `/etc/TZ`

* improved time zone changes with seperate function. timezone is now set at boot time to avoid time zone name and actual system time zone mismatch
This commit is contained in:
Jelmer Tiete
2019-02-02 12:29:27 -05:00
committed by jmtatsch
parent 64b5202e92
commit f1047c7f5e
4 changed files with 18 additions and 15 deletions

View File

@@ -1 +1 @@
Europe/London Europe/London

View File

@@ -130,7 +130,10 @@ fi
echo "udhcpc: $udhcpc_status" >> $LOGPATH echo "udhcpc: $udhcpc_status" >> $LOGPATH
## Sync the via NTP: ## Set Timezone
set_timezone
## Sync the time via NTP:
if [ ! -f $CONFIGPATH/ntp_srv.conf ]; then if [ ! -f $CONFIGPATH/ntp_srv.conf ]; then
cp $CONFIGPATH/ntp_srv.conf.dist $CONFIGPATH/ntp_srv.conf cp $CONFIGPATH/ntp_srv.conf.dist $CONFIGPATH/ntp_srv.conf
fi fi

View File

@@ -446,6 +446,15 @@ update_axis(){
fi fi
} }
# Set timezone from the timezone config file to system timezone
set_timezone(){
timezone_name=`cat /system/sdcard/config/timezone.conf`
timezone=`/system/sdcard/bin/busybox awk -F '\t' -v tzn="$timezone_name" '($1==tzn) {print $2}' /system/sdcard/www/timezones.tsv`
if [ "$(cat /etc/TZ)" != "$timezone" ]; then
echo "$timezone" > /etc/TZ
fi
}
# Reboot the System # Reboot the System
reboot_system() { reboot_system() {
/sbin/reboot /sbin/reboot

View File

@@ -196,20 +196,11 @@ if [ -n "$F_cmd" ]; then
timezone_name=$(printf '%b' "${F_timeZone//%/\\x}") timezone_name=$(printf '%b' "${F_timeZone//%/\\x}")
if [ "$(cat /system/sdcard/config/timezone.conf)" != "$timezone_name" ]; then if [ "$(cat /system/sdcard/config/timezone.conf)" != "$timezone_name" ]; then
echo "<p>Setting time zone name to '$timezone_name'...</p>" echo "<p>Setting time zone to '$timezone_name'...</p>"
echo "$timezone_name" > /system/sdcard/config/timezone.conf echo "$timezone_name" > /system/sdcard/config/timezone.conf
fi # Set system timezone from timezone name
set_timezone
timezone=$(/system/sdcard/bin/busybox awk -F '\t' -v tzn="$timezone_name" '($1==tzn) {print $2}' /system/sdcard/www/timezones.tsv) fi
if [ "$(cat /etc/TZ)" != "$timezone" ]; then
echo "<p>Setting TZ to '$timezone'...</p>"
echo "$timezone" > /etc/TZ
echo "<p>Syncing time...</p>"
if /system/sdcard/bin/busybox ntpd -q -n -p "$ntp_srv" > /dev/null 2>&1; then
echo "<p>Success</p>"
else echo "<p>Failed</p>"
fi
fi
hst=$(printf '%b' "${F_hostname//%/\\x}") hst=$(printf '%b' "${F_hostname//%/\\x}")
if [ "$(cat /system/sdcard/config/hostname.conf)" != "$hst" ]; then if [ "$(cat /system/sdcard/config/hostname.conf)" != "$hst" ]; then