timemngr: Store first use date

This commit is contained in:
Vivek Kumar Dutta 2023-09-22 08:48:51 +05:30
parent 3a1915a027
commit f59bed5f48
No known key found for this signature in database
GPG key ID: 65C818099F37097D
2 changed files with 13 additions and 1 deletions

View file

@ -5,7 +5,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=timemngr
PKG_VERSION:=1.0.2
PKG_VERSION:=1.0.3
LOCAL_DEV:=0
ifneq ($(LOCAL_DEV),1)
@ -49,12 +49,14 @@ endif
define Package/$(PKG_NAME)/install
$(INSTALL_DIR) $(1)/etc/timemngr/
$(INSTALL_DIR) $(1)/etc/hotplug.d/iface
$(INSTALL_DIR) $(1)/etc/hotplug.d/ntp
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/timemngr $(1)/usr/sbin/timemngr
$(INSTALL_DATA) $(PKG_BUILD_DIR)/src/libtimemngr.so $(1)/etc/timemngr/
$(INSTALL_DATA) ./files/etc/timemngr/input.json $(1)/etc/timemngr/
$(INSTALL_BIN) ./files/etc/hotplug.d/iface/21-timemngr $(1)/etc/hotplug.d/iface/
$(INSTALL_BIN) ./files/etc/hotplug.d/ntp/40-firstUseDate $(1)/etc/hotplug.d/ntp/
$(INSTALL_BIN) ./files/etc/init.d/timemngr $(1)/etc/init.d/
ifeq ($(CONFIG_TIMEMNGR_MIGRATE_SYSTEM),y)
$(INSTALL_DIR) $(1)/etc/uci-defaults

View file

@ -0,0 +1,10 @@
#!/bin/sh
# This hotplug script set the firstUseDate if not already set
[ "$ACTION" = stratum ] || exit 0
[ -f "/etc/config/time" ] || exit 0
if ! uci -q get time.global.first_use_date > /dev/null 2>&1; then
uci -q set time.global.first_use_date="$(date -u +'%Y-%m-%dT%H:%M:%SZ')"
uci commit time
fi