mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2025-12-10 07:44:50 +01:00
bbfdm: Register micro-services before exposing over ubus
This commit is contained in:
parent
7df39bd465
commit
d9d2fc882f
4 changed files with 41 additions and 28 deletions
|
|
@ -5,13 +5,13 @@
|
|||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=bbfdm
|
||||
PKG_VERSION:=1.12.26
|
||||
PKG_VERSION:=1.13.0
|
||||
|
||||
USE_LOCAL:=0
|
||||
ifneq ($(USE_LOCAL),1)
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://dev.iopsys.eu/bbf/bbfdm.git
|
||||
PKG_SOURCE_VERSION:=811f0616c6a861c9b78d5a079a0f79f3eb0b23b2
|
||||
PKG_SOURCE_VERSION:=c7151852374d1432c861bdbbbae105ec158a4d61
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
|
||||
PKG_MIRROR_HASH:=skip
|
||||
endif
|
||||
|
|
|
|||
|
|
@ -88,6 +88,9 @@ BBFDM_INSTALL_MS_PLUGIN:=$(BBFDM_DIR)/tools/bbfdm.sh -m -p
|
|||
#
|
||||
BBFDM_INSTALL_SCRIPT:=$(BBFDM_DIR)/tools/bbfdm.sh -s
|
||||
|
||||
|
||||
BBFDM_REGISTER_SERVICES:=$(BBFDM_DIR)/tools/bbfdm.sh -t
|
||||
|
||||
# Deprecated functions errors
|
||||
define BbfdmInstallPluginInMicroservice
|
||||
$(warning # BbfdmInstallPluginInMicroservice function is deprecated, use BBFDM_INSTALL_MS_PLUGIN macro #)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ STOP=8
|
|||
USE_PROCD=1
|
||||
PROG=/usr/sbin/dm-service
|
||||
|
||||
BBFDM_MICROSERVICE_DIR="/etc/bbfdm/micro_services"
|
||||
BBFDM_MICROSERVICE_DIR="/etc/bbfdm/services"
|
||||
|
||||
. /usr/share/libubox/jshn.sh
|
||||
|
||||
|
|
@ -24,7 +24,7 @@ validate_bbfdm_micro_service_section()
|
|||
_add_microservice()
|
||||
{
|
||||
local name path loglevel
|
||||
local enable enable_core
|
||||
local enable enable_core unified_daemon
|
||||
|
||||
# Check enable from micro-service
|
||||
path="${1}"
|
||||
|
|
@ -41,7 +41,12 @@ _add_microservice()
|
|||
log "datamodel micro-service ${name} not enabled"
|
||||
return 0
|
||||
fi
|
||||
|
||||
|
||||
json_get_var unified_daemon unified_daemon 0
|
||||
if [ "${unified_daemon}" -eq "1" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
json_select config
|
||||
json_get_var loglevel loglevel 3
|
||||
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
BBFDM_BASE_DM_PATH="usr/share/bbfdm"
|
||||
BBFDM_INPUT_PATH="etc/bbfdm/micro_services"
|
||||
INPUT_TEMPLATE='{"daemon":{"enable":"1","service_name":"template","config":{"loglevel":"3"}}}'
|
||||
OUT_NAME=""
|
||||
INPUT_FILE="0"
|
||||
|
||||
MICRO_SERVICE=0
|
||||
SCRIPT=0
|
||||
|
|
@ -13,7 +13,7 @@ DEST=""
|
|||
TOOLS="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
|
||||
SRC=""
|
||||
|
||||
while getopts ":mpsdu:" opt; do
|
||||
while getopts ":mpsdtu:" opt; do
|
||||
case ${opt} in
|
||||
m)
|
||||
MICRO_SERVICE=1
|
||||
|
|
@ -27,6 +27,9 @@ while getopts ":mpsdu:" opt; do
|
|||
d)
|
||||
DIAG=1
|
||||
;;
|
||||
t)
|
||||
INPUT_FILE=1
|
||||
;;
|
||||
u)
|
||||
OUT_NAME="${OPTARG}"
|
||||
;;
|
||||
|
|
@ -108,23 +111,6 @@ bbfdm_install_dm()
|
|||
fi
|
||||
}
|
||||
|
||||
bbfdm_generate_input()
|
||||
{
|
||||
local dest ser
|
||||
|
||||
dest_dir=${1}
|
||||
ser=${2}
|
||||
dest=${dest_dir}/${ser}.json
|
||||
|
||||
if [ -n "${OUT_NAME}" ]; then
|
||||
echo ${INPUT_TEMPLATE} | jq --arg service "${ser}" --arg OUT "${OUT_NAME}" '.daemon |= (.service_name = $service |.output.name = $OUT)' > ${dest}
|
||||
else
|
||||
echo ${INPUT_TEMPLATE} | jq --arg service "${ser}" '.daemon.service_name = $service' > ${dest}
|
||||
fi
|
||||
|
||||
chmod 466 ${dest}
|
||||
}
|
||||
|
||||
if [ -z "$SRC" ] || [ -z "${DEST}" ] ; then
|
||||
echo "# BBFDM Null value in src[${SRC}], dest[${DEST}]"
|
||||
exit 1
|
||||
|
|
@ -141,6 +127,29 @@ if [ "${SCRIPT}" -eq "1" ]; then
|
|||
exit 0
|
||||
fi
|
||||
|
||||
if [ "${INPUT_FILE}" -eq "1" ]; then
|
||||
|
||||
if [ ! -f "${SRC}" ]; then
|
||||
echo "# Datamodel Input file ${SRC} not available"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! cat ${SRC} |jq >/dev/null 2>&1; then
|
||||
echo "# Invalid datamodel json input file"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "${DATA}" ]; then
|
||||
echo "# Package name not provided ...."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
install_dir ${DEST}/etc/bbfdm/services
|
||||
install_data ${SRC} ${DEST}/etc/bbfdm/services/${DATA}.json
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "${MICRO_SERVICE}" -eq "1" ]; then
|
||||
if [ -z "${DATA}" ]; then
|
||||
echo "# service_name[${DATA}] not provided"
|
||||
|
|
@ -151,10 +160,6 @@ if [ "${MICRO_SERVICE}" -eq "1" ]; then
|
|||
extn="$(basename ${SRC})"
|
||||
install_dir ${DEST}/${BBFDM_BASE_DM_PATH}/micro_services
|
||||
bbfdm_install_dm ${SRC} ${DEST}/${BBFDM_BASE_DM_PATH}/micro_services/${DATA}.${extn##*.}
|
||||
|
||||
# main micro-service datamodel plugin, create an input file as well
|
||||
install_dir ${DEST}/${BBFDM_INPUT_PATH}
|
||||
bbfdm_generate_input ${DEST}/${BBFDM_INPUT_PATH}/ ${DATA}
|
||||
else
|
||||
install_dir ${DEST}/${BBFDM_BASE_DM_PATH}/micro_services/${DATA}
|
||||
bbfdm_install_dm ${SRC} ${DEST}/${BBFDM_BASE_DM_PATH}/micro_services/${DATA}/$(basename ${SRC})
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue