--- /dev/null
+#
+# Copyright (C) 2021 Sebastian Kemper <sebastian_ml@gmx.net>
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=coturn
+PKG_VERSION:=4.5.2
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=https://codeload.github.com/coturn/coturn/tar.gz/$(PKG_VERSION)?
+PKG_HASH:=462f1aa5c2455f28c1c8df09510d9e88ab14a1159b5e33ea5be5095262e83745
+
+PKG_LICENSE:=BSD-COTURN-CITRIX COMBINED-CITRIX-VIVOCHA-BSD MIT-HASH
+PKG_LICENSE_FILES:=LICENSE src/apps/relay/dbdrivers/* src/server/ns_turn_khash.h
+
+PKG_MAINTAINER:=Jiri Slachta <jiri@slachta.eu>, Sebastian Kemper <sebastian_ml@gmx.net>
+
+PKG_BUILD_PARALLEL:=1
+
+PKG_INSTALL:=1
+
+PKG_CONFIG_DEPENDS+= \
+ CONFIG_COTURN_ENABLE_MYSQL \
+ CONFIG_COTURN_ENABLE_POSTGRESQL \
+ CONFIG_COTURN_ENABLE_REDIS \
+ CONFIG_COTURN_ENABLE_SQLITE
+
+PKG_CPE_ID:=cpe:/a:coturn_project:coturn
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/nls.mk
+
+define Package/coturn
+ TITLE:=coturn TURN and STUN Server
+ CATEGORY:=Network
+ SECTION:=net
+ SUBMENU:=Telephony
+ URL:=https://github.com/coturn/coturn
+ USERID:=turnserver=379:turnserver=379
+ DEPENDS := \
+ +libevent2 \
+ +libevent2-extra \
+ +libevent2-pthreads \
+ +libevent2-openssl \
+ +libopenssl \
+ +COTURN_ENABLE_MYSQL:libmariadb \
+ +COTURN_ENABLE_POSTGRESQL:libpq \
+ +COTURN_ENABLE_REDIS:libhiredis \
+ +COTURN_ENABLE_SQLITE:libsqlite3
+ FILE_MODES:=/etc/turnserver:turnserver:turnserver:0750
+endef
+
+define Package/coturn/conffiles
+/etc/config/turnserver
+/etc/init.d/turnserver
+/etc/turnserver.conf
+endef
+
+define Package/coturn/config
+ menu "coturn configuration"
+ depends on PACKAGE_coturn
+
+ config COTURN_ENABLE_SQLITE
+ bool "SQLite support"
+ default y
+ help
+ Enable SQLite support
+
+ config COTURN_ENABLE_MYSQL
+ bool "MySQL support"
+ default n
+ help
+ Enable MySQL support
+
+ config COTURN_ENABLE_POSTGRESQL
+ bool "PostgreSQL support"
+ default n
+ help
+ Enable PostgreSQL support
+
+ config COTURN_ENABLE_REDIS
+ bool "Redis support"
+ default n
+ help
+ Enable Redis support
+
+ endmenu
+endef
+
+define Package/coturn/description
+The TURN Server is a VoIP media traffic NAT traversal server and
+gateway. It can be used as a general-purpose network traffic TURN server
+and gateway, too.
+endef
+
+define Package/coturn/install
+ $(INSTALL_DIR) \
+ $(1)/etc/{config,init.d,turnserver} $(1)/usr/{bin,share/coturn}
+ $(INSTALL_DATA) $(PKG_INSTALL_DIR)/etc/turnserver.conf.default \
+ $(1)/etc/turnserver.conf
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/turn* $(1)/usr/bin
+ $(INSTALL_BIN) ./files/turnserver.init \
+ $(1)/etc/init.d/turnserver
+ $(INSTALL_CONF) ./files/turnserver.conf \
+ $(1)/etc/config/turnserver
+ifneq ($(CONFIG_COTURN_ENABLE_MYSQL)$(CONFIG_COTURN_ENABLE_POSTGRESQL)$(CONFIG_COTURN_ENABLE_SQLITE),)
+ $(INSTALL_DATA) \
+ $(PKG_INSTALL_DIR)/usr/share/coturn/{schema,testsqldbsetup}.sql \
+ $(1)/usr/share/coturn
+endif
+ifneq ($(CONFIG_COTURN_ENABLE_REDIS),)
+ $(INSTALL_DATA) \
+ $(PKG_INSTALL_DIR)/usr/share/coturn/schema.{stats,userdb}.redis \
+ $(1)/usr/share/coturn
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/share/coturn/testredisdbsetup.sh \
+ $(1)/usr/share/coturn
+endif
+endef
+
+CONFIGURE_ARGS+= \
+ --disable-rpath \
+ --schemadir=/usr/share/coturn \
+ --turndbdir=/etc/turnserver
+
+CONFIGURE_VARS+= \
+ TURN_NO_PROMETHEUS=1 \
+ TURN_NO_SCTP=1 \
+ TURN_NO_SYSTEMD=1 \
+ TURN_NO_MONGO=1 \
+ $(if $(CONFIG_COTURN_ENABLE_MYSQL),,TURN_NO_MYSQL=1) \
+ $(if $(CONFIG_COTURN_ENABLE_POSTGRESQL),,TURN_NO_PQ=1) \
+ $(if $(CONFIG_COTURN_ENABLE_REDIS),,TURN_NO_HIREDIS=1) \
+ $(if $(CONFIG_COTURN_ENABLE_SQLITE),,TURN_NO_SQLITE=1)
+
+define Build/InstallDev
+endef
+
+$(eval $(call BuildPackage,coturn))
--- /dev/null
+#!/bin/sh /etc/rc.common
+
+START=90
+STOP=10
+
+USE_PROCD=1
+
+#PROCD_DEBUG=1
+
+NAME=turnserver
+COMMAND=/usr/bin/$NAME
+
+LOGGER="/usr/bin/logger -s -t $NAME"
+LOG_ERR="$LOGGER -p daemon.err --"
+
+start_service() {
+
+ config_load $NAME
+
+ config_get_bool enabled general enabled 0
+ if [ $enabled -eq 0 ]; then
+ $LOG_ERR service not enabled in /etc/config/$NAME
+ exit 1
+ fi
+
+ config_get_bool log_stderr general log_stderr 1
+ config_get_bool log_stdout general log_stdout 1
+
+ config_get options general options
+
+ procd_open_instance
+ procd_set_param command $COMMAND
+ procd_append_param command $options
+ # forward stderr to logd
+ procd_set_param stderr $log_stderr
+ # same for stdout
+ procd_set_param stdout $log_stdout
+ procd_close_instance
+}
--- /dev/null
+--- a/configure
++++ b/configure
+@@ -1034,9 +1034,9 @@ ${ECHO_CMD} "# Generated by configure sc
+ ${ECHO_CMD} "#################################" >> Makefile
+ ${ECHO_CMD} "ECHO_CMD = ${ECHO_CMD}" >> Makefile
+ ${ECHO_CMD} "CC = ${CC}" >> Makefile
+-${ECHO_CMD} "LDFLAGS += ${OSLIBS}" >> Makefile
++${ECHO_CMD} "LDFLAGS = ${OSLIBS}" >> Makefile
+ ${ECHO_CMD} "DBLIBS += ${DBLIBS}" >> Makefile
+-${ECHO_CMD} "CFLAGS += ${OSCFLAGS}" >> Makefile
++${ECHO_CMD} "CFLAGS = ${OSCFLAGS}" >> Makefile
+ ${ECHO_CMD} "CPPFLAGS = ${CPPFLAGS}" >> Makefile
+ ${ECHO_CMD} "DBCFLAGS += ${DBCFLAGS} ${TURN_NO_PQ} ${TURN_NO_MYSQL} ${TURN_NO_SQLITE} ${TURN_NO_MONGO} ${TURN_NO_HIREDIS} ${TURN_NO_SYSTEMD}" >> Makefile
+ ${ECHO_CMD} "#" >> Makefile