Pull request #52: feat(systemd-service-demo):Add a systemd demo
Merge in ICO/coreos from feat/add_systemd_services_demo to master * commit '558096e26496247d978c36b5b3cd1712255131f1': feat(systemd-service-demo):Add a systemd demo refactor(coreos-images): rename coreos-image-demo -> coreos-image-all-features
This commit is contained in:
commit
6541ac3edc
|
|
@ -100,11 +100,11 @@ the machine is set to `cn9130-cf-pro` but you can use any other MACHINE listed i
|
||||||
occurrences of `cn9130-cf-pro` to your machine when executing a command.
|
occurrences of `cn9130-cf-pro` to your machine when executing a command.
|
||||||
|
|
||||||
For an image that contains a lot of developer tools, the best image to build
|
For an image that contains a lot of developer tools, the best image to build
|
||||||
is `coreos-image-demo`.
|
is `coreos-image-all-features`.
|
||||||
|
|
||||||
.. code-block:: sh
|
.. code-block:: sh
|
||||||
|
|
||||||
~/img-build/build$ bitbake coreos-image-demo
|
~/img-build/build$ bitbake coreos-image-all-features
|
||||||
|
|
||||||
After a long time, the build system will return. You can list all the artifacts
|
After a long time, the build system will return. You can list all the artifacts
|
||||||
produced by `bitbake` using `ls`:
|
produced by `bitbake` using `ls`:
|
||||||
|
|
@ -119,7 +119,7 @@ be found with this command:
|
||||||
.. code-block:: sh
|
.. code-block:: sh
|
||||||
|
|
||||||
~/coreos/build$ find tmp/deploy/images/${MACHINE} -type l -name "*.wic.xz"
|
~/coreos/build$ find tmp/deploy/images/${MACHINE} -type l -name "*.wic.xz"
|
||||||
tmp/deploy/images/cn9130-cf-pro/coreos-image-demo-cn9130-cf-pro.wic.xz
|
tmp/deploy/images/cn9130-cf-pro/coreos-image-all-features-cn9130-cf-pro.wic.xz
|
||||||
|
|
||||||
.. hint::
|
.. hint::
|
||||||
|
|
||||||
|
|
@ -167,6 +167,6 @@ Now, flash the image file to the your card:
|
||||||
|
|
||||||
.. code-block:: sh
|
.. code-block:: sh
|
||||||
|
|
||||||
~/coreos/build$ bmaptool copy tmp/deploy/images/cn9130-cf-pro/coreos-image-demo-cn9130-cf-pro.wic.xz /dev/<DISKNAME>
|
~/coreos/build$ bmaptool copy tmp/deploy/images/cn9130-cf-pro/coreos-image-all-features-cn9130-cf-pro.wic.xz /dev/<DISKNAME>
|
||||||
|
|
||||||
You have to replace `<DISKNAME>` by the name of your SD Card device.
|
You have to replace `<DISKNAME>` by the name of your SD Card device.
|
||||||
|
|
|
||||||
|
|
@ -4,12 +4,20 @@ Images
|
||||||
|
|
||||||
The CoreOS build system provides several examples image:
|
The CoreOS build system provides several examples image:
|
||||||
|
|
||||||
.. index:: coreos-image-demo
|
.. index:: coreos-image-all-features
|
||||||
|
|
||||||
|
``coreos-image-all-features``
|
||||||
|
=============================
|
||||||
|
|
||||||
|
An image with most of the optional feature of CoreOS.
|
||||||
|
|
||||||
|
.. index:: coreos-image-demo
|
||||||
|
|
||||||
``coreos-image-demo``
|
``coreos-image-demo``
|
||||||
=============================
|
=============================
|
||||||
|
|
||||||
A image with most of the optional feature of CoreOS.
|
An image based on `coreos-image-all-features`` that has additional demo
|
||||||
|
features activated.
|
||||||
|
|
||||||
.. index:: coreos-image-minimal
|
.. index:: coreos-image-minimal
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
DESCRIPTION = "An image that come with most of the feature available in CoreOS"
|
||||||
|
|
||||||
|
inherit coreos-image
|
||||||
|
require recipes-core/images/coreos-image-all-features.bb
|
||||||
|
|
||||||
|
# demos
|
||||||
|
IMAGE_INSTALL:append = " systemd-services-demo"
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# This is a simple example for systemd start
|
||||||
|
PIPE="/tmp/bar"
|
||||||
|
if [ ! -p "$PIPE" ]; then
|
||||||
|
mkfifo $PIPE
|
||||||
|
fi
|
||||||
|
|
||||||
|
COUNTER=0
|
||||||
|
|
||||||
|
while : ; do
|
||||||
|
COUNTER=$((COUNTER + 1))
|
||||||
|
echo "Hello Service 1: ${COUNTER}" > /tmp/bar
|
||||||
|
sleep 10
|
||||||
|
done
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# This is a simple example for systemd start
|
||||||
|
|
||||||
|
PIPE="/tmp/baz"
|
||||||
|
if [ ! -p "$PIPE" ]; then
|
||||||
|
mkfifo $PIPE
|
||||||
|
fi
|
||||||
|
|
||||||
|
COUNTER=0
|
||||||
|
|
||||||
|
while : ; do
|
||||||
|
COUNTER=$((COUNTER + 1))
|
||||||
|
echo "Hello Service 2: ${COUNTER}" > /tmp/baz
|
||||||
|
sleep 10
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# This is an example for systemd-notify
|
||||||
|
# You can see the status with systemctl status demoservice3.service
|
||||||
|
|
||||||
|
|
||||||
|
PIPE="/tmp/foo"
|
||||||
|
if [ ! -p "$PIPE" ]; then
|
||||||
|
mkfifo -m 666 $PIPE
|
||||||
|
fi
|
||||||
|
|
||||||
|
sleep 10 # Assume we are doing some time consuming initialization
|
||||||
|
|
||||||
|
# Notify systemd that we are ready
|
||||||
|
systemd-notify --ready --status="Waiting for data ..."
|
||||||
|
|
||||||
|
while : ; do
|
||||||
|
read a < /tmp/foo
|
||||||
|
# Tell systemd your current status
|
||||||
|
systemd-notify --status="Processing $a"
|
||||||
|
|
||||||
|
# Do something with $a …
|
||||||
|
sleep 10
|
||||||
|
|
||||||
|
systemd-notify --status="Waiting for data ..."
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
[Unit]
|
||||||
|
Description=systemd demo
|
||||||
|
After=demoservice3.service
|
||||||
|
Wants=demoservice3.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStart=/usr/bin/demo_service_1.sh
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
[Unit]
|
||||||
|
Description=systemd demo for showing dependencies
|
||||||
|
After=demoservice3.service
|
||||||
|
Requires=demoservice3.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStart=/usr/bin/demo_service_2.sh
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
[Unit]
|
||||||
|
Description=systemd demo for showing notifications
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=notify
|
||||||
|
ExecStart=/usr/bin/demo_service_3.sh
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
DESCRIPTION = "Example that shows how services can be started by using systemd unit files"
|
||||||
|
SECTION = "examples"
|
||||||
|
DEPENDS = ""
|
||||||
|
LICENSE = "CLOSED"
|
||||||
|
|
||||||
|
FILESEXTRAPATHS:prepend := "${THISDIR}/files:"
|
||||||
|
|
||||||
|
SRC_URI = " file://demo_service_1.sh \
|
||||||
|
file://demoservice1.service \
|
||||||
|
file://demo_service_2.sh \
|
||||||
|
file://demoservice2.service \
|
||||||
|
file://demo_service_3.sh \
|
||||||
|
file://demoservice3.service \
|
||||||
|
"
|
||||||
|
|
||||||
|
inherit systemd
|
||||||
|
|
||||||
|
SYSTEMD_SERVICE:${PN} += "demoservice1.service"
|
||||||
|
SYSTEMD_SERVICE:${PN} += "demoservice2.service"
|
||||||
|
SYSTEMD_SERVICE:${PN} += "demoservice3.service"
|
||||||
|
SYSTEMD_AUTO_ENABLE = "enable"
|
||||||
|
|
||||||
|
do_install(){
|
||||||
|
install -d ${D}${bindir}
|
||||||
|
install -m 0777 ${WORKDIR}/demo_service_1.sh ${D}${bindir}
|
||||||
|
install -m 0777 ${WORKDIR}/demo_service_2.sh ${D}${bindir}
|
||||||
|
install -m 0777 ${WORKDIR}/demo_service_3.sh ${D}${bindir}
|
||||||
|
install -d ${D}${systemd_unitdir}/system
|
||||||
|
install -m 0644 ${WORKDIR}/demoservice1.service ${D}${systemd_unitdir}/system
|
||||||
|
install -m 0644 ${WORKDIR}/demoservice2.service ${D}${systemd_unitdir}/system
|
||||||
|
install -m 0644 ${WORKDIR}/demoservice3.service ${D}${systemd_unitdir}/system
|
||||||
|
}
|
||||||
|
|
||||||
|
FILES:${PN} += " ${systemd_unitdir}/system/demoservice*.service ${bindir}/demo_service_*.sh"
|
||||||
|
|
@ -7,3 +7,6 @@ IMAGE_FEATURES += "${@bb.utils.contains("MACHINE_FEATURES", "efi", "swupdate", "
|
||||||
|
|
||||||
IMAGE_INSTALL:append = " packagegroup-core-full-cmdline"
|
IMAGE_INSTALL:append = " packagegroup-core-full-cmdline"
|
||||||
IMAGE_INSTALL:append = "${@bb.utils.contains("IMAGE_FEATURES", "swupdate", " swupdate-www", "", d)}"
|
IMAGE_INSTALL:append = "${@bb.utils.contains("IMAGE_FEATURES", "swupdate", " swupdate-www", "", d)}"
|
||||||
|
|
||||||
|
# development tools
|
||||||
|
IMAGE_INSTALL:append = " systemd-analyze"
|
||||||
|
|
@ -6,12 +6,12 @@
|
||||||
Currently only a swupdate-www-push subcommand is available.
|
Currently only a swupdate-www-push subcommand is available.
|
||||||
|
|
||||||
It can be used this way:
|
It can be used this way:
|
||||||
coreos-device swupdate-www-push ~/coreos-image-demo-vm-x64.swu 192.168.122.21
|
coreos-device swupdate-www-push ~/coreos-image-all-features-vm-x64.swu 192.168.122.21
|
||||||
|
|
||||||
This script doesn't interact with bitbake so it can't retrieve variables from
|
This script doesn't interact with bitbake so it can't retrieve variables from
|
||||||
bitbake. For a more user friendly usage you can use devtool:
|
bitbake. For a more user friendly usage you can use devtool:
|
||||||
|
|
||||||
devtool swupdate-www-push coreos-image-demo 192.168.122.21
|
devtool swupdate-www-push coreos-image-all-features 192.168.122.21
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ You can now run 'bitbake <target>'
|
||||||
|
|
||||||
Common targets are:
|
Common targets are:
|
||||||
coreos-image-minimal
|
coreos-image-minimal
|
||||||
|
coreos-image-all-features
|
||||||
coreos-image-demo
|
coreos-image-demo
|
||||||
|
|
||||||
You can also run generated qemu images with a command like 'runqemu qemuarm64'.
|
You can also run generated qemu images with a command like 'runqemu qemuarm64'.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue