dhcpmngr: add dhcpmngr package to iopsys feed

* add Makefile
* move udhcpc.user.d script used for remaining dhcp lease time to
  this package
This commit is contained in:
Mohd Husaam Mehdi 2024-05-07 17:29:06 +05:30 committed by Rahul Thakur
parent 3f64f35b50
commit 9b7b0184c8
2 changed files with 64 additions and 0 deletions

50
dhcpmngr/Makefile Normal file
View file

@ -0,0 +1,50 @@
#
# Copyright (C) 2024 IOPSYS Software Solutions AB
#
include $(TOPDIR)/rules.mk
PKG_NAME:=dhcpmngr
PKG_VERSION:=1.0.0
LOCAL_DEV:=0
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/network/dhcpmngr.git
PKG_SOURCE_VERSION:=4ac13351a17b8d70f353549756f5fde4996dd134
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
PKG_MIRROR_HASH:=skip
endif
PKG_LICENSE:=BSD-3-Clause
PKG_LICENSE_FILES:=LICENSE
include $(INCLUDE_DIR)/package.mk
include ../bbfdm/bbfdm.mk
MAKE_PATH:=src
define Package/dhcpmngr
SECTION:=net
CATEGORY:=Network
TITLE:=Package to add Device.DHCPv4 and v6 data model support.
DEPENDS:=+libuci +libubox +libubus +libblobmsg-json +libjson-c +libbbfdm-api +dnsmasq
endef
define Package/dhcpmngr/description
Package to add Device.DHCPv4. and Device.DHCPv6. data model support.
endef
ifeq ($(LOCAL_DEV),1)
define Build/Prepare
$(CP) -rf ~/git/dhcpmngr/* $(PKG_BUILD_DIR)/
endef
endif
define Package/dhcpmngr/install
$(INSTALL_DIR) $(1)/etc/udhcpc.user.d
$(INSTALL_BIN) ./files/etc/udhcpc.user.d/udhcpc_lease_start_time.user $(1)/etc/udhcpc.user.d/udhcpc_lease_start_time.user
$(BBFDM_INSTALL_MS_DM) $(PKG_BUILD_DIR)/src/libdhcpmngr.so $(1) $(PKG_NAME)
endef
$(eval $(call BuildPackage,dhcpmngr))

View file

@ -0,0 +1,14 @@
#!/bin/sh
leasestarttime="$(awk -F'.' '{print $1}' /proc/uptime 2> /dev/null)"
target_file=/tmp/dhcp_client_info
target_str="$INTERFACE $lease $leasestarttime"
# if this interface is present in file, then replace it
if grep -q "$INTERFACE" "$target_file" 2> /dev/null; then
# replace the whole line if pattern matches
sed -i "/${INTERFACE}/c\\${target_str}" "$target_file"
else
# interface info was not present, append it to the file
echo "$target_str" >> "$target_file"
fi