databag: add package
authorRoland Osborne <roland.osborne@gmail.com>
Wed, 3 Apr 2024 18:58:17 +0000 (11:58 -0700)
committerRosen Penev <rosenp@gmail.com>
Mon, 24 Jun 2024 01:35:10 +0000 (18:35 -0700)
Signed-off-by: Roland Osborne <roland.osborne@gmail.com>
net/databag/Makefile [new file with mode: 0644]
net/databag/files/databag.config [new file with mode: 0644]
net/databag/files/databag.init [new file with mode: 0644]

diff --git a/net/databag/Makefile b/net/databag/Makefile
new file mode 100644 (file)
index 0000000..2430db9
--- /dev/null
@@ -0,0 +1,67 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=databag
+PKG_VERSION:=1.1.11
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=https://github.com/balzack/databag/releases/download/v$(PKG_VERSION)/server.tar.gz?
+PKG_HASH:=b4f9b46ffc9810156c6b8e50216ee4b703b5967a3a88acd982e0ce9ee42098e4
+
+PKG_MAINTAINER:=Roland Osborne <roland.osborne@gmail.com>
+PKG_LICENSE:=Apache-2.0
+PKG_LICENSE_FILES:=LICENSE
+
+PKG_BUILD_DEPENDS:=golang/host
+PKG_BUILD_PARALLEL:=1
+PKG_BUILD_FLAGS:=no-mips16
+
+GO_PKG:=databag
+
+include $(INCLUDE_DIR)/package.mk
+include ../../lang/golang/golang-package.mk
+
+TAR_CMD=$(HOST_TAR) -C $(1) $(TAR_OPTIONS)
+
+define Package/databag
+  SECTION:=net
+  CATEGORY:=Network
+  SUBMENU:=Instant Messaging
+  TITLE:=Federated Messaging Service
+  URL:=https://github.com/balzack/databag
+  DEPENDS:=$(GO_ARCH_DEPENDS)
+endef
+
+define Package/databag/description
+  Databag is a federated messaging service with browser and mobile clients.
+endef
+
+define Package/databag/conffiles
+/etc/config/databag
+endef
+
+define Download/static_web
+       URL:=https://github.com/balzack/databag/releases/download/v$(PKG_VERSION)
+       URL_FILE:=webapp.tar.gz
+       FILE:=$(PKG_NAME)-$(PKG_VERSION)-webapp.tar.gz
+       HASH:=9a9a4332a4837e356b3815fec3aacf5099d8a11dfcdad83847790d235101fa05
+endef
+
+TARGET_CFLAGS += "-D_LARGEFILE64_SOURCE"
+
+define Package/databag/install
+       $(call GoPackage/Package/Install/Bin,$(1))
+       $(INSTALL_DIR) $(1)/usr/share/databag
+       $(INSTALL_DATA) $(PKG_BUILD_DIR)/databag.db $(1)/usr/share/databag/
+       $(INSTALL_DIR) $(1)/usr/share/databag/web
+       gzip -dc $(DL_DIR)/$(PKG_NAME)-$(PKG_VERSION)-webapp.tar.gz | $(HOST_TAR) -C $(1)/usr/share/databag/web/ $(TAR_OPTIONS)
+
+       $(INSTALL_DIR) $(1)/etc/init.d
+       $(INSTALL_BIN) files/databag.init $(1)/etc/init.d/databag
+       $(INSTALL_DIR) $(1)/etc/config
+       $(INSTALL_CONF) files/databag.config $(1)/etc/config/databag
+endef
+
+$(eval $(call Download,static_web))
+$(eval $(call GoBinPackage,databag))
+$(eval $(call BuildPackage,databag))
diff --git a/net/databag/files/databag.config b/net/databag/files/databag.config
new file mode 100644 (file)
index 0000000..1b71f15
--- /dev/null
@@ -0,0 +1,12 @@
+##
+## Databag is a federated messaging service
+##
+
+config databag 'config'
+
+       ## path where database and assets are store
+       option store_path '/tmp/databag/store'
+
+       ## listening port for the service
+       option service_port '7001'
+
diff --git a/net/databag/files/databag.init b/net/databag/files/databag.init
new file mode 100644 (file)
index 0000000..d6e6e0f
--- /dev/null
@@ -0,0 +1,24 @@
+#!/bin/sh /etc/rc.common
+USE_PROCD=1
+START=50
+STOP=51
+
+start_service() {
+       # load config
+       config_load databag
+       config_get store_path "config" "store_path" "/tmp/databag/store"
+       config_get service_port "config" "service_port" "7001"
+
+       # init store
+       mkdir -p "${store_path}"
+       cp -n "/usr/share/databag/databag.db" "${store_path}"
+
+       # setup serice
+       procd_open_instance 
+       procd_set_param command "/usr/bin/databag"
+       procd_append_param command -p "${service_port}"
+       procd_append_param command -s "${store_path}"
+       procd_append_param command -w "/usr/share/databag/web/build"
+       procd_close_instance
+}