[LEDE-DEV] [PATCH RFC] owsd: add package for OpenWrt WebSocket Daemon

Rafał Miłecki zajec5 at gmail.com
Thu Mar 30 03:21:54 PDT 2017


From: Rafał Miłecki <rafal at milecki.pl>

It can be used as an alternative for uhttpd-mod-ubus. It allows
accessing ubus using WebSocket API standardized by the W3C.

Signed-off-by: Rafał Miłecki <rafal at milecki.pl>
---
Hi,

I don't know if there is any interest in this package (and if it should go to
base or external repo), but I gave it a try and so I'm sharing my code.
---
 package/system/owsd/Makefile          | 33 ++++++++++++++++++++++++++++++
 package/system/owsd/files/owsd.config |  7 +++++++
 package/system/owsd/files/owsd.init   | 38 +++++++++++++++++++++++++++++++++++
 3 files changed, 78 insertions(+)
 create mode 100644 package/system/owsd/Makefile
 create mode 100644 package/system/owsd/files/owsd.config
 create mode 100644 package/system/owsd/files/owsd.init

diff --git a/package/system/owsd/Makefile b/package/system/owsd/Makefile
new file mode 100644
index 0000000000..808911f7a4
--- /dev/null
+++ b/package/system/owsd/Makefile
@@ -0,0 +1,33 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=owsd
+PKG_RELEASE:=1
+
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL=http://public.inteno.se/owsd.git
+PKG_SOURCE_DATE:=2017-02-17
+PKG_SOURCE_VERSION:=8f62b44c37861dcacb201bbb79fa27d83ada4b48
+CMAKE_INSTALL:=1
+
+PKG_LICENSE:=GPL-2.0
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/cmake.mk
+
+define Package/owsd
+  SECTION:=base
+  CATEGORY:=Base system
+  TITLE:=OpenWrt WebSocket Daemon
+  DEPENDS:=+libwebsockets +libubox +libubus +libblobmsg-json +libopenssl
+endef
+
+define Package/owsd/install
+	$(INSTALL_DIR) $(1)/bin
+	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/owsd $(1)/bin/
+	$(INSTALL_DIR) $(1)/etc/config
+	$(INSTALL_DATA) ./files/owsd.config $(1)/etc/config/owsd
+	$(INSTALL_DIR) $(1)/etc/init.d
+	$(INSTALL_BIN) ./files/owsd.init $(1)/etc/init.d/owsd
+endef
+
+$(eval $(call BuildPackage,owsd))
diff --git a/package/system/owsd/files/owsd.config b/package/system/owsd/files/owsd.config
new file mode 100644
index 0000000000..4a9556ea43
--- /dev/null
+++ b/package/system/owsd/files/owsd.config
@@ -0,0 +1,7 @@
+config global global
+	option enabled		0
+
+config port
+	option port		80
+	list origin		http://127.0.0.1
+	list origin		http://192.168.1.1
diff --git a/package/system/owsd/files/owsd.init b/package/system/owsd/files/owsd.init
new file mode 100644
index 0000000000..b129f39abb
--- /dev/null
+++ b/package/system/owsd/files/owsd.init
@@ -0,0 +1,38 @@
+#!/bin/sh /etc/rc.common
+
+START=95
+STOP=10
+
+USE_PROCD=1
+PROG=/bin/owsd
+
+handle_port() {
+	local config="$1"
+	local __resultvar="$2"
+	local _args=""
+	local port interface origin
+
+	config_get port $config port
+	[ -n "$port" ] && _args="$_args -p $port"
+	config_get interface $config interface
+	[ -n "$interface" ] && _args="$_args -i $interface"
+	config_get origin $config origin
+	[ -n "$origin" ] && _args="$_args -o ${origin/ / -o }"
+
+	args="$args$_args"
+}
+
+start_service() {
+	local enabled
+
+	config_load owsd
+
+	config_get_bool enabled global enabled 0
+	[ $enabled -eq 0 ] && return
+
+	config_foreach handle_port port
+
+	procd_open_instance
+	procd_set_param command "$PROG" $args
+	procd_close_instance
+}
-- 
2.11.0




More information about the Lede-dev mailing list