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.
hfreyther/master-next
Holger Hans Peter Freyther 9 years ago
parent e7fadd8e8e
commit 018ef1a599

@ -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
}

@ -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

@ -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
Loading…
Cancel
Save