# Copyright 2019 University of Warsaw

include $(TOPDIR)/rules.mk

PKG_NAME:=status-led
PKG_VERSION:=1.0.0
PKG_RELEASE:=1
PKG_LICENSE:=MIT
PKG_LICENSE_FILES:=License

include $(INCLUDE_DIR)/package.mk

define Package/status-led
  SECTION:=heni
  CATEGORY:=HENI
  TITLE:=Script handling the system LED
  DEPENDS:=+
endef

define Package/status-led/description
 Show connection and VPN status on the system LED.
endef

define Build/Compile
endef

define Build/Configure
endef

define Package/status-led/install
	$(INSTALL_DIR) $(1)/etc
	$(INSTALL_DIR) $(1)/etc/init.d
	$(INSTALL_DIR) $(1)/usr
	$(INSTALL_DIR) $(1)/usr/bin
	$(INSTALL_BIN) ./files/etc/init.d/status-led $(1)/etc/init.d/status-led
	$(INSTALL_BIN) ./files/usr/bin/status-led $(1)/usr/bin/status-led
endef

define Package/status-led/postinst
#!/bin/sh
if [ -z "$${IPKG_INSTROOT}" ]; then
        echo "Enabling rc.d symlink for status-led"
        /etc/init.d/status-led enable
fi
exit 0
endef

define Package/status-led/prerm
#!/bin/sh
if [ -z "$${IPKG_INSTROOT}" ]; then
        echo "Removing rc.d symlink for status-led"
        /etc/init.d/status-led disable
fi
exit 0
endef

$(eval $(call BuildPackage,status-led))
