#
# Copyright (c) 2022 Genexis B.V.
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License 2.0 which is available at
# https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
#   Erik Karlsson - initial implementation
#

include $(TOPDIR)/rules.mk

PKG_NAME:=mosquitto-auth-shadow
PKG_VERSION:=1.0.1

PKG_MAINTAINER:=Erik Karlsson <erik.karlsson@genexis.eu>
PKG_LICENSE:=EPL-2.0

PKG_BUILD_PARALLEL:=1

include $(INCLUDE_DIR)/package.mk

define Package/mosquitto-auth-shadow
  SECTION:=net
  CATEGORY:=Network
  TITLE:=mosquitto - /etc/shadow authentication plugin
  DEPENDS:=+mosquitto-ssl
  USERID:=mosquitto=200:mosquitto=200 mosquitto=200:shadow=11
endef

define Package/mosquitto-auth-shadow/description
  Plugin for the mosquitto MQTT message broker that authenticates
  users using /etc/shadow
endef

define Package/mosquitto-auth-shadow/install
	$(INSTALL_DIR) $(1)/usr/lib
	$(INSTALL_BIN) $(PKG_BUILD_DIR)/mosquitto_auth_shadow.so $(1)/usr/lib/
	$(CP) ./files/* $(1)/
endef

$(eval $(call BuildPackage,mosquitto-auth-shadow))
