Module: meta-angstrom Branch: master Commit: e003be8cba3d387f44a502fdbebf58e774afd677
Author: Koen Kooi <k...@dominion.thruhere.net> Date: Fri Nov 11 14:58:50 2011 +0100 timestap-service: /etc/timestamp support for systemd Signed-off-by: Koen Kooi <k...@dominion.thruhere.net> --- recipes-core/systemd/timestamp-service.bb | 29 ++++++++++++++++++++ .../systemd/timestamp-service/load-timestamp.sh | 22 +++++++++++++++ .../systemd/timestamp-service/timestamp.service | 12 ++++++++ 3 files changed, 63 insertions(+), 0 deletions(-) diff --git a/recipes-core/systemd/timestamp-service.bb b/recipes-core/systemd/timestamp-service.bb new file mode 100644 index 0000000..be8325e --- /dev/null +++ b/recipes-core/systemd/timestamp-service.bb @@ -0,0 +1,29 @@ +DESCRIPTION = "Poor mans RTC using timestamps" +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=3f40d7994397109285ec7b81fdeb3b58" + +inherit allarch systemd + +SRC_URI = "file://timestamp.service \ + file://load-timestamp.sh \ + " + +do_compile() { + : +} + + +do_install () { + install -d ${D}/${bindir} + + install -m 0755 ${WORKDIR}/load-timestamp.sh ${D}/${bindir} + + install -d ${D}/${base_libdir}/systemd/system + install -m 0644 ${WORKDIR}/timestamp.service ${D}/${base_libdir}/systemd/system/ +} + +SYSTEMD_PACKAGES = "${PN}" +SYSTEMD_SERVICE_${PN} = "timestamp.service" + +FILES_${PN} += "${base_libdir}/systemd" + diff --git a/recipes-core/systemd/timestamp-service/load-timestamp.sh b/recipes-core/systemd/timestamp-service/load-timestamp.sh new file mode 100755 index 0000000..82c69f6 --- /dev/null +++ b/recipes-core/systemd/timestamp-service/load-timestamp.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +# Set the system clock from hardware clock +# If the timestamp is 1 day or more recent than the current time, +# use the timestamp instead. +SYSTEMDATE=$(/bin/date -u "+%4Y%2m%2d%2H%2M") + +YEAR=$(cat /etc/timestamp | cut -b 9-12) +MONTH=$(cat /etc/timestamp | cut -b 1-2) +DAY=$(cat /etc/timestamp | cut -b 3-4) +TIME=$(cat /etc/timestamp | cut -b 5-8) + +TIMESTAMP="$YEAR$MONTH$DAY$TIME" + +if [ $SYSTEMDATE -lt $TIMESTAMP ]; then + echo "Update systemtime from /etc/timestamp" + date -u $(cat /etc/timestamp) +fi + +if [ "$1" = "--save" ] ; then + /bin/date -u +%2m%2d%2H%2M%4Y > /etc/timestamp +fi diff --git a/recipes-core/systemd/timestamp-service/timestamp.service b/recipes-core/systemd/timestamp-service/timestamp.service new file mode 100644 index 0000000..9be5056 --- /dev/null +++ b/recipes-core/systemd/timestamp-service/timestamp.service @@ -0,0 +1,12 @@ +[Unit] +Description=Timestamping service +ConditionPathExists=/etc/timestamp +After=remount-rootfs.service + +[Service] +RemainAfterExit=yes +ExecStart=/usr/bin/load-timestamp.sh +ExecStop=/usr/bin/load-timestamp.sh --save + +[Install] +WantedBy=basic.target _______________________________________________ Angstrom-distro-devel mailing list Angstrom-distro-devel@linuxtogo.org http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/angstrom-distro-devel