[meta-intel] [meta-intel-iot-devkit] [PATCH] timedate-scripts: fix date and time format in set-initial-date script

rebecca.swee.fun.chang at intel.com rebecca.swee.fun.chang at intel.com
Thu May 28 04:16:26 PDT 2015


From: Chang Rebecca Swee Fun <rebecca.swee.fun.chang at intel.com>

The date and time format was invalid in the script causing script
execution error when system is up. This patch is to fix the date/time
setting scripts with correct date/time format in order for the script
to execute correctly.

This patch also includes code clean up by removing trailing whitespaces
in some of the lines and removing empty lines at the end of file.

Suggested-by: Brendan Le Foll <brendan.le.foll at intel.com>
Signed-off-by: Chang Rebecca Swee Fun <rebecca.swee.fun.chang at intel.com>
---
 .../timedate-scripts/files/set-initial-date        | 28 ++++++++++------------
 1 file changed, 13 insertions(+), 15 deletions(-)

diff --git a/recipes-support/timedate-scripts/files/set-initial-date b/recipes-support/timedate-scripts/files/set-initial-date
index ecb41da..3c28408 100755
--- a/recipes-support/timedate-scripts/files/set-initial-date
+++ b/recipes-support/timedate-scripts/files/set-initial-date
@@ -8,14 +8,14 @@
 if [[ ! -f /etc/version ]]; then
   echo "error: set-initial-date - didn't find /etc/version"
   exit 1
-fi 
-d0=$(cat /etc/version) 
+fi
+d0=$(cat /etc/version)
 # timestamp date
-d1=$(date -r /etc/version +'%Y%m%d%H%M')
+d1=$(date -r /etc/version +'%4Y%2m%2d%2H%2M')
 # current date
-d2=$(date +'%Y%m%d%H%M')
+d2=$(date +'%4Y%2m%2d%2H%2M')
 
-# take the latest date - will also work if $d0 is empty 
+# take the latest date - will also work if $d0 is empty
 if [[ $d0 -gt $d1 ]]; then
   d=$d0
 else
@@ -27,17 +27,15 @@ if [[ $d2 -gt $d ]]; then
   exit 0
 fi
 
-# timedatectl requires d-bus - 
-# we attempt to set date & time as early as possible hence we use 'date' 
-# rather than 
+# timedatectl requires d-bus -
+# we attempt to set date & time as early as possible hence we use 'date'
+# rather than
 # timedatectl set-time "${d:0:4}-${d:4:2}-${d:6:2} ${d:8:2}:${d:10:2}:00"
 
-# set date                                  
-date -s ${d::8} > /dev/null
-# set time                                  
-date -s ${d:8} > /dev/null
-# set hwclock in UTZ
+# set date
+date -s ${d--8} > /dev/null
+# set time
+date -s ${d-8} > /dev/null
+# set hwclock in UTC
 export TZ=UTC
 hwclock -w
-
-
-- 
1.9.1



More information about the meta-intel mailing list