From 018ef1a59992947a5954db5969d8ea257a5fc467 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Fri, 18 Jul 2014 10:59:52 +0200 Subject: [PATCH] early-date: Introduce a simple hacked up script to set an initial time If the year is smaller than < 2014 an initial date will be set. This has been manually verified by copying ntpdate to ntpdate.off and making sure that the VPN is coming up. Due the short SSL lifetime of CACert we will need to update the script once in a while. But our VPN should now always come up. --- recipes-bsp/early-date/early-date_1.bb | 23 +++++++++++++++++++ recipes-bsp/early-date/files/early-date | 10 ++++++++ .../early-date/files/early-date.service | 14 +++++++++++ 3 files changed, 47 insertions(+) create mode 100644 recipes-bsp/early-date/early-date_1.bb create mode 100755 recipes-bsp/early-date/files/early-date create mode 100644 recipes-bsp/early-date/files/early-date.service diff --git a/recipes-bsp/early-date/early-date_1.bb b/recipes-bsp/early-date/early-date_1.bb new file mode 100644 index 0000000..a1b22d8 --- /dev/null +++ b/recipes-bsp/early-date/early-date_1.bb @@ -0,0 +1,23 @@ +DESCRIPTION = "Set an early date on RTC less systems" +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=3f40d7994397109285ec7b81fdeb3b58" + +SRC_URI = "\ + file://early-date \ + file://early-date.service" + +FILES_${PN} = "${systemd_unitdir}/system /sbin" +RDPEPENDS_${PN} = "systemd" + +do_install() { + install -d ${D}/sbin + install -d ${D}${systemd_unitdir}/system/basic.target.wants + + # Copy the service file and link it + install -m 0644 ${WORKDIR}/early-date.service ${D}${systemd_unitdir}/system + ln -sf ../early-date.service ${D}${systemd_unitdir}/system/basic.target.wants/ + + # Hardcode to /sbin + # TODO: Set the date as of the build time.. + install -m 0755 ${WORKDIR}/early-date ${D}/sbin +} diff --git a/recipes-bsp/early-date/files/early-date b/recipes-bsp/early-date/files/early-date new file mode 100755 index 0000000..15a7bbb --- /dev/null +++ b/recipes-bsp/early-date/files/early-date @@ -0,0 +1,10 @@ +#!/bin/sh + +# Check if the year is lower than the lowest configured and then +# set a default date +YEAR=`date +%Y` + +if [ $YEAR -lt 2014 ]; then + date -s 2014.07.18-10:00:00 + hwclock -w +fi diff --git a/recipes-bsp/early-date/files/early-date.service b/recipes-bsp/early-date/files/early-date.service new file mode 100644 index 0000000..9e2bf87 --- /dev/null +++ b/recipes-bsp/early-date/files/early-date.service @@ -0,0 +1,14 @@ +[Unit] +Description=Early boot time for RTC less systems +DefaultDependencies=no +After=systemd-remount-fs.service +Before=sysinit.target + +[Service] +ExecStart=/sbin/early-date +RemainAfterExit=No +Type=oneshot +StandardOutput=syslog + +[Install] +WantedBy=basic.target