tang: updated to version 12
authorNikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
Wed, 12 Apr 2023 18:19:10 +0000 (20:19 +0200)
committerNikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
Sun, 7 May 2023 18:47:02 +0000 (20:47 +0200)
This version enables standalone operation.

Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
utils/tang/Makefile
utils/tang/files/config [new file with mode: 0644]
utils/tang/files/tang.init [new file with mode: 0644]
utils/tang/files/tang.upgrade [new file with mode: 0644]
utils/tang/files/tangdw [deleted file]
utils/tang/files/tangdx [deleted file]

index 6dff7c88c44b900decbfb0b18be5667ad0f93791..005fe4d50ca60b949fe22e00daeb42e4fafc0d1d 100644 (file)
@@ -8,12 +8,12 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=tang
-PKG_VERSION:=11
-PKG_RELEASE:=3
+PKG_VERSION:=12
+PKG_RELEASE:=1
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
 PKG_SOURCE_URL:=https://github.com/latchset/$(PKG_NAME)/releases/download/v$(PKG_VERSION)/
-PKG_HASH:=ef5d3ae56030f20c290594b9be89ad9ec469dd385676595e1c7a2bfdc3f45d8f
+PKG_HASH:=892e0b26ee2db01f2c257b083fbb85aede7d3f59de7361c9c9528c0d5783e69c
 
 PKG_MAINTAINER:=Tibor Dudlák <tibor.dudlak@gmail.com>
 PKG_LICENSE:=GPL-3.0-or-later
@@ -25,7 +25,7 @@ include $(INCLUDE_DIR)/meson.mk
 define Package/tang
   SECTION:=utils
   TITLE:=tang v$(PKG_VERSION) - daemon for binding data to the presence of a third party
-  DEPENDS:=+libhttp-parser +xinetd +jose +bash
+  DEPENDS:=+libhttp-parser +jose +bash
   URL:=https://github.com/latchset/tang
 endef
 
@@ -34,18 +34,18 @@ define Package/tang/description
 endef
 
 define Package/tang/conffiles
-/etc/xinetd.d/tangdx
 /usr/share/tang/db/
 endef
 
 define Package/tang/install
        $(INSTALL_DIR)  $(1)/usr/bin
        $(INSTALL_DIR)  $(1)/usr/libexec
-       $(INSTALL_DIR)  $(1)/etc/xinetd.d/
        $(INSTALL_BIN)  $(PKG_INSTALL_DIR)/usr/bin/tang-show-keys       $(1)/usr/bin/
        $(INSTALL_BIN)  $(PKG_INSTALL_DIR)/usr/libexec/tangd*           $(1)/usr/libexec/
-       $(INSTALL_BIN)  ./files/tangdw                                  $(1)/usr/libexec/
-       $(CP)           ./files/tangdx                                  $(1)/etc/xinetd.d/
+       $(INSTALL_DIR)  $(1)/etc/init.d
+       $(INSTALL_BIN)  ./files/tang.init $(1)/etc/init.d/tang
+       $(INSTALL_DIR)  $(1)/etc/config
+       $(INSTALL_CONF) ./files/config $(1)/etc/config/tang
 endef
 
 define Package/tang/postinst
@@ -54,10 +54,8 @@ if [ -z "$${IPKG_INSTROOT}" ]; then
        mkdir -p /usr/share/tang/db
        KEYS=$(find /usr/share/tang/db/ -name "*.jw*" -maxdepth 1 | wc -l)
        if [ "${KEYS}" = "0" ]; then # if db is empty generate new key pair
-               /usr/libexec/tangd-keygen /usr/share/tang/db/
+               /usr/libexec/tangd-keygen /usr/share/tang/db
        fi
-       (cat /etc/services | grep -E "tangd.*8888\/tcp") > /dev/null \
-               || echo -e "tangd\t\t8888/tcp" >> /etc/services
 fi
 endef
 
diff --git a/utils/tang/files/config b/utils/tang/files/config
new file mode 100644 (file)
index 0000000..1b37d3d
--- /dev/null
@@ -0,0 +1,4 @@
+config tang 'config'
+       option port '9090'
+       option enabled '0'
+
diff --git a/utils/tang/files/tang.init b/utils/tang/files/tang.init
new file mode 100644 (file)
index 0000000..9ce89c1
--- /dev/null
@@ -0,0 +1,24 @@
+#!/bin/sh /etc/rc.common
+
+START=50
+USE_PROCD=1
+
+start_service() {
+       KEYS=$(find /usr/share/tang/db -name "*.jw*" -maxdepth 1 | wc -l)
+       if [ -z "${KEYS}" ] || [ "${KEYS}" = "0" ]; then # if db is empty generate new key pair
+               mkdir -p /usr/share/tang/db
+               /usr/libexec/tangd-keygen /usr/share/tang/db
+       fi
+
+       config_load "tang"
+       config_get_bool enabled "config" "enabled" 0
+       config_get port "config" "port" "9090"
+
+       [ "${enabled}" = "1" ] || return
+
+       procd_open_instance
+       procd_set_param command /usr/libexec/tangd -p "${port}" -l /usr/share/tang/db
+       procd_set_param respawn
+       procd_set_param user tang
+       procd_close_instance
+}
diff --git a/utils/tang/files/tang.upgrade b/utils/tang/files/tang.upgrade
new file mode 100644 (file)
index 0000000..82623f6
--- /dev/null
@@ -0,0 +1 @@
+/usr/share/tang/db/*.jw*
diff --git a/utils/tang/files/tangdw b/utils/tang/files/tangdw
deleted file mode 100755 (executable)
index 91c8a89..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/sh
-echo "==================================" >> /var/log/tangd.log
-echo `date`: >> /var/log/tangd.log
-/usr/libexec/tangd $1 2>> /var/log/tangd.log
diff --git a/utils/tang/files/tangdx b/utils/tang/files/tangdx
deleted file mode 100644 (file)
index bd2134e..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-service tangd
-{
-    port            = 8888
-    socket_type     = stream
-    wait            = no
-    user            = root
-    server          = /usr/libexec/tangdw
-    server_args     = /usr/share/tang/db
-    log_on_success  += USERID
-    log_on_failure  += USERID
-    disable         = no
-}