Skip to content

Commit

Permalink
fix(vendor.viomi): Fix system timezone in init script (#876)
Browse files Browse the repository at this point in the history
  • Loading branch information
depau committed Apr 29, 2021
1 parent dd05c51 commit 908d5dd
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions deployment/viomi/etc/init.d/valetudo
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,33 @@ USE_PROCD=1
PROG=/mnt/UDISK/valetudo
OOM_ADJ=-17

_fix_timezone() {
zonename="$(/sbin/uci get 'system.@system[0].zonename')"
timezone="$(/sbin/uci get 'system.@system[0].timezone'))"
changed=0

# Force system timezone to UTC instead of Shanghai
[ "$zonename" != "UTC" ] && /sbin/uci set 'system.@system[0].zonename=UTC' && changed=1
[ "$timezone" != "UTC" ] && /sbin/uci set 'system.@system[0].timezone=UTC' && changed=1

# Remove Chinese NTP servers
if /sbin/uci get 'system.ntp.server' | grep -q 'aliyun.com'; then
/sbin/uci -q delete 'system.ntp.server'
/sbin/uci add_list 'system.ntp.server=0.pool.ntp.org'
/sbin/uci add_list 'system.ntp.server=1.pool.ntp.org'
/sbin/uci add_list 'system.ntp.server=2.pool.ntp.org'
/sbin/uci add_list 'system.ntp.server=3.pool.ntp.org'
changed=1
fi

if [ $changed != 0 ]; then
/sbin/uci commit system
/etc/init.d/sysntpd restart
fi
}

start_service() {
_fix_timezone

procd_open_instance
procd_set_param env VALETUDO_CONFIG_PATH=/mnt/UDISK/valetudo_config.json
Expand Down

0 comments on commit 908d5dd

Please sign in to comment.