summaryrefslogtreecommitdiffstats
path: root/recipes-test/demo-config/primary-config.bb
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-test/demo-config/primary-config.bb')
-rw-r--r--recipes-test/demo-config/primary-config.bb68
1 files changed, 68 insertions, 0 deletions
diff --git a/recipes-test/demo-config/primary-config.bb b/recipes-test/demo-config/primary-config.bb
new file mode 100644
index 0000000..27cb553
--- /dev/null
+++ b/recipes-test/demo-config/primary-config.bb
@@ -0,0 +1,68 @@
1DESCRIPTION = "Sample configuration for an Uptane Primary to support IP/Posix Secondary"
2LICENSE = "MPL-2.0"
3LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MPL-2.0;md5=815ca599c9df247a0c7f619bab123dad"
4
5require shared-conf.inc
6
7PRIMARY_SECONDARIES ?= "${SECONDARY_IP}:${SECONDARY_PORT}"
8
9SRC_URI = "\
10 file://30-secondary-config.toml \
11 file://ip_secondary_config.json \
12 "
13
14def get_secondary_addrs(d):
15 import json
16
17 secondaries = d.getVar('PRIMARY_SECONDARIES')
18 sec_array = []
19 for secondary in secondaries.split():
20 sec_array.append({"addr": secondary})
21
22 return json.dumps(sec_array)
23
24do_install () {
25
26 if [ ! -n "${SOTA_SECONDARY_CONFIG}" ]; then
27 bbwarn "SOTA_SECONDARY_CONFIG hasn't been specified in the local config, generate a default one"
28
29 IP_SECONDARY_CONFIG_FILE=${WORKDIR}/ip_secondary_config.json
30 IP_SECONDARY_ADDRS='${@get_secondary_addrs(d)}'
31 else
32 bbwarn "SOTA_SECONDARY_CONFIG has been specified in the local config: ${SOTA_SECONDARY_CONFIG}"
33
34 IP_SECONDARY_CONFIG_FILE=${SOTA_SECONDARY_CONFIG}
35 fi
36
37 if [ ! -f $IP_SECONDARY_CONFIG_FILE ]; then
38 bbfatal "Secondary config file does not exist: $IP_SECONDARY_CONFIG_FILE"
39 fi
40
41 SECONDARY_CONFIG_DEST_DIR="${D}${sysconfdir}/sota/ecus"
42 SECONDARY_CONFIG_DEST_FILEPATH=$SECONDARY_CONFIG_DEST_DIR/$(basename -- $IP_SECONDARY_CONFIG_FILE)
43 SECONDARY_CONFIG_FILEPATH_ON_IMAGE="${sysconfdir}/sota/ecus/$(basename -- $IP_SECONDARY_CONFIG_FILE)"
44
45 # install the secondary configuration file (json)
46 install -m 0700 -d $SECONDARY_CONFIG_DEST_DIR
47 install -m 0644 $IP_SECONDARY_CONFIG_FILE $SECONDARY_CONFIG_DEST_DIR
48
49 # if SOTA_SECONDARY_CONFIG/secondary config file is not defined in the local conf
50 # then a default template is used and filled with corresponding configuration variable values
51 if [ ! -n "${SOTA_SECONDARY_CONFIG}" ]; then
52 sed -i -e "s|@PORT@|${PRIMARY_PORT}|g" \
53 -e "s|@TIMEOUT@|${PRIMARY_WAIT_TIMEOUT}|g" \
54 -e "s|@ADDR_ARRAY@|$IP_SECONDARY_ADDRS|g" $SECONDARY_CONFIG_DEST_FILEPATH
55 fi
56
57 # install aktualizr config file (toml) that points to the secondary config file, so aktualizr is aware about it
58 install -m 0700 -d ${D}${libdir}/sota/conf.d
59 install -m 0644 ${WORKDIR}/30-secondary-config.toml ${D}${libdir}/sota/conf.d
60 sed -i "s|@CFG_FILEPATH@|$SECONDARY_CONFIG_FILEPATH_ON_IMAGE|g" ${D}${libdir}/sota/conf.d/30-secondary-config.toml
61}
62
63FILES_${PN} = " \
64 ${libdir}/sota/conf.d/* \
65 ${sysconfdir}/sota/ecus/* \
66 "
67
68# vim:set ts=4 sw=4 sts=4 expandtab: