diff --git a/hostmngr/Config.in b/hostmngr/Config.in new file mode 100644 index 000000000..7c051e2e5 --- /dev/null +++ b/hostmngr/Config.in @@ -0,0 +1,15 @@ +if (PACKAGE_hostmngr) + +menu "Configuration" + +config HOSTMNGR_HOSTS_HISTORY + bool "Keep history of hosts" + default y + +config HOSTMNGR_PLATFORM_HAS_WIFI + bool "Platform has WiFi" + default y if PACKAGE_libwifi + +endmenu + +endif diff --git a/hostmngr/Makefile b/hostmngr/Makefile new file mode 100644 index 000000000..778cb31f9 --- /dev/null +++ b/hostmngr/Makefile @@ -0,0 +1,70 @@ +# +# Copyright (C) 2020-2023 IOPSYS Software Solutions AB +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=hostmngr +PKG_VERSION:=0.16.0 + +LOCAL_DEV=0 +ifneq ($(LOCAL_DEV),1) +PKG_SOURCE_PROTO:=git +PKG_SOURCE_VERSION:=8f8f5f6d29bf6bc9fe714b7dbf7caf5211b99c57 +PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/hostmngr.git +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)_$(PKG_SOURCE_VERSION).tar.xz +PKG_MIRROR_HASH:=skip +endif +PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION) + +PKG_MAINTAINER:=Anjan Chanda +PKG_LICENSE:=BSD-3-Clause +PKG_LICENSE_FILES:=LICENSE + +include $(INCLUDE_DIR)/package.mk + + +define Package/hostmngr + SECTION:=utils + CATEGORY:=Utilities + TITLE:=Show and manage hosts in the network + DEPENDS= +libubox +libuci +libubus +ubus +libeasy +libnl-genl \ + +libjson-c +libblobmsg-json +libnfnetlink +libmnl \ + +libnetfilter-conntrack \ + +HOSTMNGR_PLATFORM_HAS_WIFI:libwifi +endef + +define Package/hostmngr/config + source "$(SOURCE)/Config.in" +endef + +define Package/hostmngr/description + This package provides hostmngr that can detect and show host devices + present in the network. +endef + +TARGET_CFLAGS += \ + -I$(STAGING_DIR)/usr/include \ + -I$(STAGING_DIR)/usr/include/libnl3 \ + -I$(STAGING_DIR)/usr/include/libnetfilter_conntrack \ + -D_GNU_SOURCE + +ifeq ($(CONFIG_HOSTMNGR_PLATFORM_HAS_WIFI),y) +TARGET_CFLAGS += -DHAS_WIFI +endif + +MAKE_PATH:=src + +define Package/hostmngr/install + $(CP) ./files/* $(1)/ + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/hostmngr $(1)/usr/sbin/ +endef + +ifeq ($(LOCAL_DEV),1) +define Build/Prepare + rsync -r --exclude=.* ~/git/hostmngr/ $(PKG_BUILD_DIR)/ +endef +endif + +$(eval $(call BuildPackage,hostmngr)) diff --git a/hostmngr/files/etc/config/hostmngr b/hostmngr/files/etc/config/hostmngr new file mode 100644 index 000000000..187fb90a6 --- /dev/null +++ b/hostmngr/files/etc/config/hostmngr @@ -0,0 +1,9 @@ + +config global 'global' + option enabled '1' + option history '1' + option history_file '/etc/hosts_history.json' + option history_timeout '604800' + +config interface + list ifname 'br-lan' diff --git a/hostmngr/files/etc/init.d/hostmngr b/hostmngr/files/etc/init.d/hostmngr new file mode 100755 index 000000000..88ff33e00 --- /dev/null +++ b/hostmngr/files/etc/init.d/hostmngr @@ -0,0 +1,26 @@ +#!/bin/sh /etc/rc.common + +START=97 +STOP=20 + +USE_PROCD=1 + +start_service() { + procd_open_instance + procd_set_param command "/usr/sbin/hostmngr" "--config hostmngr" "-o" "/tmp/hostmngr.log" "-f" +# procd_set_param respawn + procd_set_param limits core="unlimited" +# procd_set_param stdout 1 +# procd_set_param stderr 1 + procd_close_instance +} + +service_triggers() +{ + procd_add_reload_trigger "hostmngr" +} + +reload_service() { + stop + start +} diff --git a/iop/config b/iop/config index 33650f383..8a28335da 100644 --- a/iop/config +++ b/iop/config @@ -59,6 +59,7 @@ CONFIG_PACKAGE_inbd=y CONFIG_PACKAGE_qosmngr=y CONFIG_PACKAGE_libwifiutils=y CONFIG_PACKAGE_wifimngr=y +CONFIG_PACKAGE_hostmngr=y # Multi-AP # CONFIG_PACKAGE_ieee1905=y