Compare commits

...

6 Commits
vcl ... obuspa

Author SHA1 Message Date
Vivek Dutta
592f937aef obuspa: Added forked repo
Description:
 - Changes in patch files moved to forked obuspa repository
2019-06-14 18:11:23 +05:30
Vivek Dutta
f3f1f501cc obuspa: Replace ubus system command with libubus 2019-06-11 18:37:54 +05:30
Vivek Dutta
a87b268817 obuspa: Initialise dm instances from uspd on startup
Test Done:
 - Verified get/set of datamodel instance objects.
   ex:
 ~~~
 root@iopsys:~# obuspa -c get Device.WiFi.SSID.1.
 Device.WiFi.SSID.1.Alias => cpe-1
 Device.WiFi.SSID.1.BSSID => 00:22:07:6D:5E:DC
 Device.WiFi.SSID.1.Enable => 1
 Device.WiFi.SSID.1.LowerLayers => Device.WiFi.Radio.1.
 Device.WiFi.SSID.1.Name => iopsys-5ED8
 Device.WiFi.SSID.1.SSID => iopsys-5ED8
 Device.WiFi.SSID.1.Stats.BytesReceived => 0
 Device.WiFi.SSID.1.Stats.BytesSent => 0
 Device.WiFi.SSID.1.Stats.PacketsReceived => 0
 Device.WiFi.SSID.1.Stats.PacketsSent => 0
 Device.WiFi.SSID.1.status =>
 root@iopsys:~#
 root@iopsys:~# obuspa -c instances Device.WiFi.SSID.
 Device.WiFi.SSID.1
 Device.WiFi.SSID.2
 Device.WiFi.SSID.3
 root@iopsys:~# obuspa -c set Device.WiFi.SSID.1.SSID iopsy-2g
 Device.WiFi.SSID.1.SSID => iopsy-2g
 root@iopsys:~# obuspa -c get Device.WiFi.SSID.1.SSID
 Device.WiFi.SSID.1.SSID => iopsy-2g
 ~~~
2019-06-10 14:32:39 +05:30
vdutta
e3a0cafc0f obuspa: Datamodel init from libdatamodel 2019-06-06 10:00:24 +05:30
vdutta
7bed0e4f83 obuspa: Added config and init script 2019-05-13 17:03:44 +05:30
vdutta
066bfd92ce obuspa: Added usp agent package 2019-05-06 17:06:34 +05:30
3 changed files with 171 additions and 0 deletions

52
obuspa/Makefile Normal file
View File

@@ -0,0 +1,52 @@
#
# Copyright (C) 2019 Iopsys
#
include $(TOPDIR)/rules.mk
PKG_NAME:=obuspa
PKG_VERSION:=1.0.0
PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=e16b48cbebb1b19d2989833b03cc1aeea5ff4171
PKG_SOURCE_URL:=git@dev.iopsys.eu:fork/obuspa.git
PKG_SOURCE:=$(PKG_NAME)-$(PKG_SOURCE_VERSION).tar.gz
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PKG_FIXUP:=autoreconf
include $(INCLUDE_DIR)/package.mk
define Package/obuspa
SECTION:=utils
CATEGORY:=Utilities
TITLE:=USP agent
DEPENDS:=+libcoap +libopenssl +libcurl +libsqlite3 +libcares +libubox +libubus +libblobmsg-json
endef
define Package/obuspa/description
OB-USP-AGENT is a system daemon providing a User Services Platform (USP) Agent.
endef
TARGET_CFLAGS += \
-I$(STAGING_DIR)/usr/include \
-D_GNU_SOURCE
ifneq ($(CONFIG_USE_MUSL),)
TARGET_CFLAGS += -DUSE_MUSL
endif
#define Build/Prepare
# $(CP) -rf ./obuspa/* $(PKG_BUILD_DIR)/
#endef
define Package/obuspa/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_BIN) $(PKG_BUILD_DIR)/obuspa $(1)/usr/sbin/
$(CP) ./files/* $(1)/
endef
$(eval $(call BuildPackage,obuspa))

View File

@@ -0,0 +1,14 @@
config controller
option endpointid 'self::usp-controller.com'
config mtp
option enable 'true'
option protocol 'STOMP'
option destination 'uspq'
config connection
option host 'usp-controller.com'
option username 'username'
option password 'password'
option encryption 'false'

105
obuspa/files/etc/init.d/obuspa Executable file
View File

@@ -0,0 +1,105 @@
#!/bin/sh /etc/rc.common
START=99
USE_PROCD=1
PROG=/usr/sbin/obuspa
CTRL_PATH="Device.LocalAgent.Controller.1."
MTP_PATH="Device.LocalAgent.MTP.1."
CONN_PATH="Device.STOMP.Connection.1."
log() {
echo "${@}"|logger -t obuspa -p debug
}
db_set() {
log "DBSET param|${1}| value|${2}|"
${PROG} -c dbset ${1} ${2}
}
validate_controller_section()
{
uci_validate_section obuspa controller "${1}" \
'endpointid:string:"self:usp-controller.com"'
}
validate_mtp_section()
{
uci_validate_section obuspa mtp "${1}" \
'enable:bool:true' \
'protocol:string:"STOMP"' \
'destination:string:'
}
validate_connection_section()
{
uci_validate_section obuspa connection "${1}" \
'host:string:"usp-controller.com"' \
'username:string:username' \
'password:string:password' \
'encryption:bool:true'
}
configure_controller() {
local endpointid
validate_controller_section "${1}" || {
log "Validation of section failed"
return 1;
}
db_set "${CTRL_PATH}EndpointID" ${endpointid}
}
configure_mtp() {
local protocol enable destination
validate_mtp_section "${1}" || {
log "Validation of section failed"
return 1;
}
db_set "${MTP_PATH}Enable" ${enable}
db_set "${MTP_PATH}Protocol" ${protocol}
db_set "${MTP_PATH}STOMP.Destination" ${destination}
}
configure_connection() {
local host username password encryption
validate_connection_section "${1}" || {
log "Validation of section failed"
return 1;
}
db_set "${CONN_PATH}Host" ${host}
db_set "${CONN_PATH}Username" ${username}
db_set "${CONN_PATH}Password" ${password}
db_set "${CONN_PATH}X_ARRIS-COM_EnableEncryption" ${encryption}
}
db_init() {
[ -f /tmp/usp.db ] && rm -f /tmp/usp.db
config_load obuspa
config_foreach configure_controller controller
config_foreach configure_mtp mtp
config_foreach configure_connection connection
}
start_service() {
db_init
procd_open_instance
procd_set_param command ${PROG}
procd_append_param command -p -v 4
procd_set_param respawn
procd_close_instance
}
reload_service() {
stop
start
}
service_triggers() {
procd_add_config_trigger "config.change" "obuspa" /etc/init.d/obuspa restart
}