Skip to content

Commit 3141fb6

Browse files
committed
tang: Add package tang into tree
Tang is lightweight server for binding data to network presence. --- Tang's source: https://github.com/latchset/tang Maintainer: @Tiboris Compile tested: (mips, TL-WR842N, 17.01.4, r3560-79f57e422d) **Tang requires a few other software libraries:** 1. libhttp-parser: 2. xinetd's socket activation 3. jose >= 8: **Compared to tang upstream:** ***Two new files:*** - tangdx : configuration file for xinetd - tangdw : wrapper for tangd service - puts timestamp when service activated, and - redirects stderr to log file in /var/log/ ***Removed systemd requirement and nagios program*** Signed-off-by: Tibor Dudlák <tdudlak@redhat.com>
1 parent 5800538 commit 3141fb6

File tree

6 files changed

+164
-0
lines changed

6 files changed

+164
-0
lines changed

utils/tang/Makefile

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#
2+
# Copyright (C) 2018 OpenWrt.org
3+
#
4+
# This is free software, licensed under the GNU General Public License v2.
5+
# See /LICENSE for more information.
6+
#
7+
8+
include $(TOPDIR)/rules.mk
9+
10+
PKG_NAME:=tang
11+
PKG_VERSION:=6
12+
PKG_RELEASE:=1
13+
14+
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
15+
PKG_SOURCE_URL:=https://github.com/latchset/$(PKG_NAME)/releases/download/v$(PKG_VERSION)/
16+
PKG_HASH:=1df78b48a52d2ca05656555cfe52bd4427c884f5a54a2c5e37a7b39da9e155e3
17+
18+
PKG_INSTALL:=1
19+
PKG_BUILD_PARALLEL:=1
20+
21+
PKG_FIXUP:=autoreconf
22+
23+
include $(INCLUDE_DIR)/package.mk
24+
25+
define Package/tang
26+
SECTION:=utils
27+
TITLE:=tang v$(PKG_VERSION) - daemon for binding data to the presence of a third party
28+
DEPENDS:=+libhttp-parser +xinetd +jose +bash
29+
URL:=https://github.com/latchset/tang
30+
endef
31+
32+
define Package/tang/description
33+
Tang is a small daemon for binding data to the presence of a third party.
34+
endef
35+
36+
define Package/tang/install
37+
$(INSTALL_DIR) $(1)/usr/libexec
38+
$(INSTALL_DIR) $(1)/etc/xinetd.d/
39+
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/libexec/tangd* $(1)/usr/libexec/
40+
$(INSTALL_BIN) ./files/tangdw $(1)/usr/libexec/
41+
$(CP) ./files/tangdx $(1)/etc/xinetd.d/
42+
endef
43+
44+
define Package/tang/postinst
45+
#!/bin/sh
46+
if [ -z "$${IPKG_INSTROOT}" ]; then
47+
mkdir -p /usr/share/tang/db && mkdir -p /usr/share/tang/cache
48+
KEYS=$(find /usr/share/tang/db/ -name "*.jw*" -maxdepth 1 | wc -l)
49+
if [ "${KEYS}" = "0" ]; then # if db is empty generate new key pair
50+
/usr/libexec/tangd-keygen /usr/share/tang/db/
51+
elif [ "${KEYS}" = "1" ]; then # having 1 key should not happen
52+
(>&2 echo "Please check the Tang's keys in /usr/share/tang/db \
53+
and regenate cache using /usr/libexec/tangd-update script.")
54+
else
55+
/usr/libexec/tangd-update /usr/share/tang/db/ /usr/share/tang/cache/
56+
fi
57+
(cat /etc/services | grep -E "tangd.*8888\/tcp") > /dev/null \
58+
|| echo -e "tangd\t\t8888/tcp" >> /etc/services
59+
fi
60+
endef
61+
62+
$(eval $(call BuildPackage,tang))

utils/tang/files/tangdw

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
echo "========================================" >> /var/log/tangd.log
3+
echo `date`: >> /var/log/tangd.log
4+
/usr/libexec/tangd $1 2>> /var/log/tangd.log

utils/tang/files/tangdx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
service tangd
2+
{
3+
port = 8888
4+
socket_type = stream
5+
wait = no
6+
user = root
7+
server = /usr/libexec/tangdw
8+
server_args = /usr/share/tang/cache
9+
log_on_success += USERID
10+
log_on_failure += USERID
11+
disable = no
12+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
diff --git a/Makefile.am b/Makefile.am
2+
index 14bf91d..7fa8bdf 100644
3+
--- a/Makefile.am
4+
+++ b/Makefile.am
5+
@@ -1,5 +1,3 @@
6+
-DISTCHECK_CONFIGURE_FLAGS = --with-systemdsystemunitdir=$$dc_install_base/$(systemdsystemunitdir)
7+
-
8+
AM_CFLAGS = @TANG_CFLAGS@ @jose_CFLAGS@
9+
LDADD = @jose_LIBS@ @http_parser_LIBS@
10+
11+
@@ -7,13 +5,6 @@ nagiosdir = $(libdir)/nagios/plugins
12+
cachedir = $(localstatedir)/cache/$(PACKAGE_NAME)
13+
jwkdir = $(localstatedir)/db/$(PACKAGE_NAME)
14+
15+
-nodist_systemdsystemunit_DATA = \
16+
- units/tangd@.service \
17+
- units/tangd.socket \
18+
- units/tangd-update.path \
19+
- units/tangd-update.service \
20+
- units/tangd-keygen.service
21+
-
22+
dist_libexec_SCRIPTS = src/tangd-update src/tangd-keygen
23+
libexec_PROGRAMS = src/tangd
24+
nagios_PROGRAMS = src/tang
25+
@@ -34,9 +25,7 @@ src_tang_SOURCES = src/nagios.c
26+
AM_TESTS_ENVIRONMENT = SD_ACTIVATE="@SD_ACTIVATE@" PATH=$(srcdir)/src:$(builddir)/src:$(PATH)
27+
TESTS = tests/adv tests/rec tests/nagios
28+
29+
-CLEANFILES = $(nodist_systemdsystemunit_DATA)
30+
EXTRA_DIST = \
31+
- $(foreach unit,$(nodist_systemdsystemunit_DATA),$(unit).in) \
32+
COPYING \
33+
$(TESTS) \
34+
$(man1_MANS) \
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
diff --git a/configure.ac b/configure.ac
2+
index b51bb31..4b37d30 100644
3+
--- a/configure.ac
4+
+++ b/configure.ac
5+
@@ -27,32 +27,6 @@ AC_CHECK_LIB([http_parser], [http_parser_execute],
6+
[AC_MSG_ERROR([http-parser required!])])
7+
8+
PKG_CHECK_MODULES([jose], [jose >= 8])
9+
-PKG_CHECK_MODULES([systemd], [systemd])
10+
-
11+
-AC_ARG_WITH([systemdsystemunitdir],
12+
- [AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files])],
13+
- [],
14+
- [with_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)])
15+
-
16+
-AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])
17+
-
18+
-for ac_prog in systemd-socket-activate systemd-activate; do
19+
- AC_CHECK_PROG([SD_ACTIVATE], [$ac_prog], [$as_dir/$ac_prog], [],
20+
- [$PATH$PATH_SEPARATOR$($PKG_CONFIG --variable=systemdutildir systemd)])
21+
- test -n "$SD_ACTIVATE" && break
22+
-done
23+
-
24+
-test -n "$SD_ACTIVATE" || AC_MSG_ERROR([systemd-socket-activate required!])
25+
-
26+
-AC_MSG_CHECKING([systemd-socket-activate inetd flag])
27+
-if $SD_ACTIVATE --help | grep -q inetd; then
28+
- SD_ACTIVATE="$SD_ACTIVATE --inetd"
29+
- AC_MSG_RESULT([--inetd])
30+
-else
31+
- AC_MSG_RESULT([(default)])
32+
-fi
33+
-
34+
-AC_SUBST(SD_ACTIVATE)
35+
36+
TANG_CFLAGS="\
37+
-Wall \
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
diff --git a/src/tangd-update b/src/tangd-update
2+
index 652dbef..01aa842 100755
3+
--- a/src/tangd-update
4+
+++ b/src/tangd-update
5+
@@ -33,8 +33,8 @@ fi
6+
7+
[ ! -d "$2" ] && mkdir -p -m 0700 "$2"
8+
9+
-src=`realpath "$1"`
10+
-dst=`realpath "$2"`
11+
+src=`readlink -f "$1"`
12+
+dst=`readlink -f "$2"`
13+
14+
payl=()
15+
sign=()

0 commit comments

Comments
 (0)