meta-digi-dey: dey-examples: add recipe to install 'connectcore-demo' example

The ConnectCore Demo is launched on startup and starts the web server. Demo can be accessed
by any computer in the LAN by just typing the IP address of the device in the web browser.

Signed-off-by: David Escalona <david.escalona@digi.com>
This commit is contained in:
David Escalona 2022-07-13 16:33:53 +02:00
parent dc84be34bf
commit 39e41c1d7f
5 changed files with 122 additions and 0 deletions

View File

@ -0,0 +1,3 @@
# Copyright (C) 2022 Digi International.
require connectcore-demo-example.inc

View File

@ -0,0 +1,57 @@
# Copyright (C) 2022 Digi International.
require dey-examples-src.inc
SUMMARY = "Connectcore demo"
DESCRIPTION = "Connectcore demo"
SECTION = "examples"
LICENSE = "GPL-2.0-only"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/GPL-2.0-only;md5=801f80980d171dd6425610833a22dbe6"
SRC_URI += " \
file://connectcore-demo-example-init \
file://connectcore-demo-example.service \
"
RDEPENDS:${PN} = " \
python3-core \
python3-httplib2 \
python3-json \
python3-logging \
python3-netserver \
busybox-httpd \
"
S = "${WORKDIR}/connectcore-demo-example"
inherit systemd update-rc.d
do_install() {
install -d ${D}/srv/www
cp -r ${WORKDIR}/git/connectcore-demo-example/* ${D}/srv/www/
if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
# Install systemd unit files
install -d ${D}${systemd_unitdir}/system
install -m 0644 ${WORKDIR}/connectcore-demo-example.service ${D}${systemd_unitdir}/system/
fi
# connectcore-demo-example-init
install -d ${D}${sysconfdir}/init.d/
install -m 755 ${WORKDIR}/connectcore-demo-example-init ${D}${sysconfdir}/connectcore-demo-example
ln -sf /etc/connectcore-demo-example ${D}${sysconfdir}/init.d/connectcore-demo-example
}
FILES:${PN} += " \
/srv/www/* \
${systemd_unitdir}/system/connectcore-demo-example.service \
${sysconfdir}/connectcore-demo-example \
${sysconfdir}/init.d/connectcore-demo-example \
"
INITSCRIPT_NAME = "connectcore-demo-example"
INITSCRIPT_PARAMS = "start 19 2 3 4 5 . stop 21 0 1 6 ."
SYSTEMD_SERVICE:${PN} = "connectcore-demo-example.service"
PACKAGE_ARCH = "${MACHINE_ARCH}"

View File

@ -0,0 +1,50 @@
#!/bin/sh
#===============================================================================
#
# Copyright (C) 2022 by Digi International Inc.
# All rights reserved.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 as published by
# the Free Software Foundation.
#
#
# !Description: Initialize the ConnectCore demo example
#
#===============================================================================
# Source function library
. /etc/init.d/functions
readonly DEMOSERVER_BINARY="/srv/www/demoserver.py"
readonly STOP_TIMEOUT="5"
stop_process() {
# try to stop gracefully
killproc "${1}" >/dev/null 2>&1
for i in $(seq ${STOP_TIMEOUT}); do
pid=$(pidofproc "${1}") || break
if [ "${i}" -eq ${STOP_TIMEOUT} ]; then
kill -KILL "${pid}" >/dev/null 2>&1
fi
sleep 1
done
}
case "$1" in
start)
${DEMOSERVER_BINARY} > /dev/null 2>&1 &
;;
stop)
stop_process "${DEMOSERVER_BINARY}"
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
;;
esac

View File

@ -0,0 +1,11 @@
[Unit]
Description=Initialization of the ConnectCore demo example
After=busybox-httpd.service
[Service]
Type=forking
ExecStart=/etc/connectcore-demo-example start
ExecStop=/etc/connectcore-demo-example stop
[Install]
WantedBy=multi-user.target

View File

@ -21,6 +21,7 @@ RDEPENDS:${PN} = "\
dey-examples-cloudconnector \
dey-examples-digiapix \
dey-examples-rtc \
connectcore-demo-example \
"
RDEPENDS:${PN}:append:ccimx6 = "\
${@bb.utils.contains("MACHINE_FEATURES", "accel-graphics", "dey-examples-opengles", "", d)} \