bbfdm: bbfdm.mk option to override ubus object name

This commit is contained in:
Vivek Kumar Dutta 2024-05-17 16:08:58 +05:30 committed by Amin Ben Romdhane
parent 4862dec4d9
commit bf5a6f6c3b
2 changed files with 49 additions and 3 deletions

View file

@ -47,6 +47,7 @@ BBFDM_INSTALL_CORE_PLUGIN:=$(BBFDM_DIR)/tools/bbfdm.sh -p
# Note:
# - There could be only one main plugin file, so its bind to PKG_NAME
# - Micro-service input.json will be auto generated with this call
# - Use -u (optional argument) to overwrite ubus object name
#
# Example:
# BBFDM_INSTALL_MS_DM $(PKG_BUILD_DIR)/libcwmp.so $(1) $(PKG_NAME)
@ -69,6 +70,23 @@ BBFDM_INSTALL_MS_DM:=$(BBFDM_DIR)/tools/bbfdm.sh -m
#
BBFDM_INSTALL_MS_PLUGIN:=$(BBFDM_DIR)/tools/bbfdm.sh -m -p
# Utility to install the helper scripts in default bbfdm script path
#
# Use Case:
# User want to install some script for running diagnostics
#
# ARGS:
# $1 => Script with complete path
# $2 => package install directory
#
# Note:
# - Use with -d option to install script in bbf.diag directory
#
# Example:
# BBFDM_INSTALL_SCRIPT $(PKG_BUILD_DIR)/download $(1)
# BBFDM_INSTALL_SCRIPT -d $(PKG_BUILD_DIR)/ipping $(1)
#
BBFDM_INSTALL_SCRIPT:=$(BBFDM_DIR)/tools/bbfdm.sh -s
# Deprecated functions errors
define BbfdmInstallPluginInMicroservice

View file

@ -2,15 +2,18 @@
BBFDM_BASE_DM_PATH="usr/share/bbfdm"
BBFDM_INPUT_PATH="etc/bbfdm/micro_services"
INPUT_TEMPLATE='{"daemon":{"service_name":"template","config":{"loglevel":"1"}}}'
INPUT_TEMPLATE='{"daemon":{"enable":"1","service_name":"template","config":{"loglevel":"1"}}}'
OUT_NAME=""
MICRO_SERVICE=0
SCRIPT=0
DIAG=0
PLUGIN=0
DEST=""
TOOLS="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
SRC=""
while getopts ":mp" opt; do
while getopts ":mpsdu:" opt; do
case ${opt} in
m)
MICRO_SERVICE=1
@ -18,6 +21,15 @@ while getopts ":mp" opt; do
p)
PLUGIN=1
;;
s)
SCRIPT=1
;;
d)
DIAG=1
;;
u)
OUT_NAME="${OPTARG}"
;;
?)
echo "Invalid option: ${OPTARG}"
exit 1
@ -99,7 +111,12 @@ bbfdm_generate_input()
ser=${2}
dest=${dest_dir}/${ser}.json
echo ${INPUT_TEMPLATE} | jq --arg service "$ser" '.daemon.service_name = $service' > ${dest}
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}
}
@ -108,6 +125,17 @@ if [ -z "$SRC" ] || [ -z "${DEST}" ] ; then
exit 1
fi
if [ "${SCRIPT}" -eq "1" ]; then
if [ "${DIAG}" -eq "1" ]; then
install_dir ${DEST}/${BBFDM_BASE_DM_PATH}/scripts/bbf_diag
install_bin ${SRC} ${DEST}/${BBFDM_BASE_DM_PATH}/scripts/bbf_diag/
else
install_dir ${DEST}/${BBFDM_BASE_DM_PATH}/scripts
install_bin ${SRC} ${DEST}/${BBFDM_BASE_DM_PATH}/scripts/
fi
exit 0
fi
if [ "${MICRO_SERVICE}" -eq "1" ]; then
if [ -z "${DATA}" ]; then
echo "# service_name[${DATA}] not provided"