diff --git a/meta-digi-dey/recipes-digi/dey-examples/connectcore-demo-example.bb b/meta-digi-dey/recipes-digi/dey-examples/connectcore-demo-example.bb new file mode 100644 index 000000000..6dcfdbbc2 --- /dev/null +++ b/meta-digi-dey/recipes-digi/dey-examples/connectcore-demo-example.bb @@ -0,0 +1,3 @@ +# Copyright (C) 2022 Digi International. + +require connectcore-demo-example.inc diff --git a/meta-digi-dey/recipes-digi/dey-examples/connectcore-demo-example.inc b/meta-digi-dey/recipes-digi/dey-examples/connectcore-demo-example.inc new file mode 100644 index 000000000..dc945880c --- /dev/null +++ b/meta-digi-dey/recipes-digi/dey-examples/connectcore-demo-example.inc @@ -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}" diff --git a/meta-digi-dey/recipes-digi/dey-examples/connectcore-demo-example/connectcore-demo-example-init b/meta-digi-dey/recipes-digi/dey-examples/connectcore-demo-example/connectcore-demo-example-init new file mode 100644 index 000000000..4c802a91d --- /dev/null +++ b/meta-digi-dey/recipes-digi/dey-examples/connectcore-demo-example/connectcore-demo-example-init @@ -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 diff --git a/meta-digi-dey/recipes-digi/dey-examples/connectcore-demo-example/connectcore-demo-example.service b/meta-digi-dey/recipes-digi/dey-examples/connectcore-demo-example/connectcore-demo-example.service new file mode 100644 index 000000000..fd7ec7a3b --- /dev/null +++ b/meta-digi-dey/recipes-digi/dey-examples/connectcore-demo-example/connectcore-demo-example.service @@ -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 diff --git a/meta-digi-dey/recipes-digi/packagegroups/packagegroup-dey-examples.bb b/meta-digi-dey/recipes-digi/packagegroups/packagegroup-dey-examples.bb index a9bb35ab9..eab2ee218 100644 --- a/meta-digi-dey/recipes-digi/packagegroups/packagegroup-dey-examples.bb +++ b/meta-digi-dey/recipes-digi/packagegroups/packagegroup-dey-examples.bb @@ -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)} \