mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2025-12-24 11:05:02 +08:00
Compare commits
6 Commits
mcproxy_ma
...
obuspa
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
592f937aef | ||
|
|
f3f1f501cc | ||
|
|
a87b268817 | ||
|
|
e3a0cafc0f | ||
|
|
7bed0e4f83 | ||
|
|
066bfd92ce |
52
obuspa/Makefile
Normal file
52
obuspa/Makefile
Normal 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))
|
||||
14
obuspa/files/etc/config/obuspa
Normal file
14
obuspa/files/etc/config/obuspa
Normal 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
105
obuspa/files/etc/init.d/obuspa
Executable 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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user