cccs: add CCCS_CONF_PATH variable to define custom cccs configuration file

If 'CCCS_CONF_PATH' is defined, the specified file is installed as CCCS
configuration file without any modification.
It it is not defined or it is empty, the configuration file in cc_dey
('cc_dey/cccs-daemon/cfg_files/cccs.conf') is installed and modified if
required.

Signed-off-by: Tatiana Leon <Tatiana.Leon@digi.com>
This commit is contained in:
Tatiana Leon 2024-01-12 16:10:52 +01:00
parent efb80f3806
commit 721039df6b
1 changed files with 40 additions and 7 deletions

View File

@ -16,6 +16,7 @@ CC_GITHUB = "gitsm://github.com/digi-embedded/cc_dey.git;protocol=https"
CC_GIT_URI ?= "${@oe.utils.conditional('DIGI_INTERNAL_GIT', '1' , '${CC_STASH}', '${CC_GITHUB}', d)}" CC_GIT_URI ?= "${@oe.utils.conditional('DIGI_INTERNAL_GIT', '1' , '${CC_STASH}', '${CC_GITHUB}', d)}"
CCCS_DEVICE_TYPE ?= "${MACHINE}" CCCS_DEVICE_TYPE ?= "${MACHINE}"
CCCS_CONF_PATH ?= ""
SRC_URI = " \ SRC_URI = " \
${CC_GIT_URI};branch=${SRCBRANCH} \ ${CC_GIT_URI};branch=${SRCBRANCH} \
@ -24,9 +25,26 @@ SRC_URI = " \
file://cccs-gs-demo-init \ file://cccs-gs-demo-init \
file://cccs-gs-demo.service \ file://cccs-gs-demo.service \
" "
SRC_URI:append = "${@oe.utils.ifelse(d.getVar('CCCS_CONF_PATH'), \
oe.utils.ifelse(d.getVar('CCCS_CONF_PATH').startswith('/'), "file://%s" % d.getVar('CCCS_CONF_PATH'), d.getVar('CCCS_CONF_PATH')), '')}"
S = "${WORKDIR}/git" S = "${WORKDIR}/git"
# The configuration file can be provided by the user, so provide a PREMIRROR to
# a local directory that can be configured in the project's local.conf file
# using CCCS_CONF_PATH variable.
python() {
cccs_conf_path = d.getVar('CCCS_CONF_PATH')
if cccs_conf_path:
premirrors = d.getVar('PREMIRRORS')
if cccs_conf_path.startswith('/'):
cccs_conf_path = "file://%s" % cccs_conf_path
d.setVar('PREMIRRORS', "%s %s \\n %s" % (cccs_conf_path, cccs_conf_path, premirrors))
cccs_conf_sha256 = d.getVar('CCCS_CONF_SHA256')
if cccs_conf_sha256:
d.setVarFlag("SRC_URI", "sha256sum", cccs_conf_sha256)
}
inherit pkgconfig systemd update-rc.d inherit pkgconfig systemd update-rc.d
do_install() { do_install() {
@ -45,15 +63,29 @@ do_install() {
install -m 755 ${WORKDIR}/cccs-gs-demo-init ${D}${sysconfdir}/cccs-gs-demo install -m 755 ${WORKDIR}/cccs-gs-demo-init ${D}${sysconfdir}/cccs-gs-demo
ln -sf /etc/cccs-gs-demo ${D}${sysconfdir}/init.d/cccs-gs-demo ln -sf /etc/cccs-gs-demo ${D}${sysconfdir}/init.d/cccs-gs-demo
# Set the device type. Its maximum length is 255 characters if [ -n "${CCCS_CONF_PATH}" ]; then
[ -z "${CCCS_DEVICE_TYPE}" ] && device_type="${MACHINE}" || device_type="${CCCS_DEVICE_TYPE}" CONF="${CCCS_CONF_PATH}"
device_type="$(echo "${device_type}" | cut -c1-255)" if [ "${CONF#file://}" != "${CONF}" ]; then
sed -i "/device_type = .*/c\device_type = \"${device_type}\"" ${D}${sysconfdir}/cccs.conf CONF="${CONF#file://}"
elif [ "${CONF#/}" != "${CONF}" ]; then
CONF="${CONF}"
else
CONF="${WORKDIR}/$(basename ${CONF})"
fi
install -m 0644 "${CONF}" ${D}${sysconfdir}/cccs.conf
else
# Set the device type. Its maximum length is 255 characters
[ -z "${CCCS_DEVICE_TYPE}" ] && device_type="${MACHINE}" || device_type="${CCCS_DEVICE_TYPE}"
device_type="$(echo "${device_type}" | cut -c1-255)"
sed -i "/device_type = .*/c\device_type = \"${device_type}\"" ${D}${sysconfdir}/cccs.conf
fi
} }
do_install:append:ccimx6ul() { do_install:append:ccimx6ul() {
sed -i "/url = \"edp12.devicecloud.com\"/c\url = \"remotemanager.digi.com\"" ${D}${sysconfdir}/cccs.conf if [ -z "${CCCS_CONF_PATH}" ]; then
sed -i "/client_cert_path = \"\/mnt\/data\/drm_cert.pem\"/c\client_cert_path = \"\/etc\/ssl\/certs\/drm_cert.pem\"" ${D}${sysconfdir}/cccs.conf sed -i "/url = \"edp12.devicecloud.com\"/c\url = \"remotemanager.digi.com\"" ${D}${sysconfdir}/cccs.conf
sed -i "/client_cert_path = \"\/mnt\/data\/drm_cert.pem\"/c\client_cert_path = \"\/etc\/ssl\/certs\/drm_cert.pem\"" ${D}${sysconfdir}/cccs.conf
fi
} }
pkg_postinst_ontarget:${PN}() { pkg_postinst_ontarget:${PN}() {
@ -64,7 +96,8 @@ pkg_postinst_ontarget:${PN}() {
fi fi
} }
inherit ${@bb.utils.contains("IMAGE_FEATURES", "read-only-rootfs", "remove-pkg-postinst-ontarget", "", d)} inherit ${@bb.utils.contains("IMAGE_FEATURES", "read-only-rootfs", "remove-pkg-postinst-ontarget", \
oe.utils.ifelse(d.getVar("CCCS_CONF_PATH"), "remove-pkg-postinst-ontarget", ""), d)}
INITSCRIPT_PACKAGES = "${PN}-daemon ${PN}-gs-demo" INITSCRIPT_PACKAGES = "${PN}-daemon ${PN}-gs-demo"
INITSCRIPT_NAME:${PN}-daemon = "cccsd" INITSCRIPT_NAME:${PN}-daemon = "cccsd"