19526acb2SLei YU#!/bin/bash 29526acb2SLei YU 39526acb2SLei YUset -e 49526acb2SLei YU 59526acb2SLei YU# Get time from ME via ipmb 69526acb2SLei YU# The last 4 bytes are the epoch time, e.g. 79526acb2SLei YU# (iyyyyay) 0 11 0 72 0 4 18 169 82 95 89526acb2SLei YUret=$(busctl call xyz.openbmc_project.Ipmi.Channel.Ipmb "/xyz/openbmc_project/Ipmi/Channel/Ipmb" org.openbmc.Ipmb sendRequest yyyyay 0x01 0x0a 0x00 0x48 0) 99526acb2SLei YU 109526acb2SLei YUIFS=' ' read -r -a a <<< "${ret}" 119526acb2SLei YU 129526acb2SLei YUif [ "${a[1]}" -ne 0 ] 139526acb2SLei YUthen 149526acb2SLei YU echo "Failed to get time from ME: ${ret}" 159526acb2SLei YU exit 1 169526acb2SLei YUfi 179526acb2SLei YU 18*58826718SPatrick Williamst0=$((a[7])) 19*58826718SPatrick Williamst1=$((a[8]*256)) 20*58826718SPatrick Williamst2=$((a[9]*256*256)) 21*58826718SPatrick Williamst3=$((a[10]*256*256*256)) 22*58826718SPatrick Williamst=$((t0+t1+t2+t3)) 239526acb2SLei YUecho "Setting date to ${t}" 249526acb2SLei YU 259526acb2SLei YUdate -s @${t} 26