diff mbox

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

Message ID 20170330102154.3243-1-zajec5@gmail.com
State RFC
Headers show

Commit Message

Rafał Miłecki March 30, 2017, 10:21 a.m. UTC
From: Rafał Miłecki <rafal@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@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

Comments

Denis Osvald March 31, 2017, 1:01 p.m. UTC | #1
Hi Rafał,

On 2017-03-30 12:21, Rafał Miłecki wrote:
> 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.


owsd was written by me for Inteno. It's used in the JUCI web UI.
Our plans for inclusion were to:
- move the source and development to a GitHub Inteno Group account
- make owsd (partially or completely) compatible with LUCI for backwards
compatibility
- include owsd in the not-yet-created prplwrt feed

From my POV, it is of course good if to go in the base or any other feed
as well especially if it is made LUCI compatible.

As for the patch, we have a more complete package in the following
repository:

http://public.inteno.se/?p=feed-inteno-juci.git;a=tree;f=net/owsd;h=8b57f49368be50999e209ca8d706c3de496ace73

Next week I will send a patch for the more complete owsd package,
and I will keep you, Rafał, In the loop.


Regards,

Denis
diff mbox

Patch

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
+}