ccmp15: connectcore demo: fix autostart of demo application on top of weston
This commit is similar to those required to launch crank applications on top of
weston in ConnectCore MP 15 platform, it must wait for the socket
'/run/user/0/wayland-1' after weston is initialized.
See commits 7de8270beda64236cdd1c46857906315a37dc4fe and
1ec5cc172c.
Signed-off-by: Tatiana Leon <Tatiana.Leon@digi.com>
This commit is contained in:
parent
b305808539
commit
feea2179ad
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/sh
|
||||
#===============================================================================
|
||||
#
|
||||
# Copyright (C) 2022 by Digi International Inc.
|
||||
# Copyright (C) 2022, 2023 by Digi International Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it
|
||||
|
|
@ -16,10 +16,26 @@
|
|||
# Source function library
|
||||
. /etc/init.d/functions
|
||||
|
||||
readonly DEMO_DISPLAY="##CC_DEMO_DISPLAY##"
|
||||
readonly DEMO_ENV="##CC_DEMO_ENV##"
|
||||
readonly COG_BINARY="/usr/bin/cog"
|
||||
readonly DEMOSERVER_BINARY="/srv/www/demoserver.py"
|
||||
readonly STOP_TIMEOUT="5"
|
||||
|
||||
wait_for_wayland() {
|
||||
local count=20
|
||||
local wayland_socket="/run/user/0/${DEMO_DISPLAY}"
|
||||
|
||||
while [ ! -S "${wayland_socket}" ]; do
|
||||
sleep 1
|
||||
count=$((count-1))
|
||||
if [ "${count}" = 0 ]; then
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
return 0
|
||||
}
|
||||
|
||||
stop_process() {
|
||||
# try to stop gracefully
|
||||
killproc "${1}" >/dev/null 2>&1
|
||||
|
|
@ -32,35 +48,43 @@ stop_process() {
|
|||
done
|
||||
}
|
||||
|
||||
export_environment_variables() {
|
||||
export DISPLAY=:0.0
|
||||
export XDG_RUNTIME_DIR=/run/user/0
|
||||
export WAYLAND_DISPLAY=wayland-0
|
||||
export COG_PLATFORM_WL_VIEW_FULLSCREEN=1
|
||||
# FULLSCREEN variable will have preference over other geometry variables.
|
||||
if [ -f "/sys/class/graphics/fb0/virtual_size" ]; then
|
||||
COG_PLATFORM_WL_VIEW_WIDTH="$(cut -d',' -f1 /sys/class/graphics/fb0/virtual_size)"
|
||||
COG_PLATFORM_WL_VIEW_HEIGHT="$(cut -d',' -f2 /sys/class/graphics/fb0/virtual_size)"
|
||||
[ -n "${COG_PLATFORM_WL_VIEW_WIDTH}" ] && export COG_PLATFORM_WL_VIEW_WIDTH
|
||||
[ -n "${COG_PLATFORM_WL_VIEW_HEIGHT}" ] && export COG_PLATFORM_WL_VIEW_HEIGHT
|
||||
fi
|
||||
stop() {
|
||||
stop_process "${COG_BINARY}"
|
||||
stop_process "${DEMOSERVER_BINARY}"
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
${DEMOSERVER_BINARY} > /dev/null 2>&1 &
|
||||
export_environment_variables
|
||||
${COG_BINARY} \
|
||||
start() {
|
||||
local COG_ENV="${DEMO_ENV}"
|
||||
|
||||
${DEMOSERVER_BINARY} > /dev/null 2>&1 &
|
||||
|
||||
if [ -d "/usr/share/wayland" ]; then
|
||||
wait_for_wayland
|
||||
COG_ENV="${COG_ENV} COG_PLATFORM_WL_VIEW_FULLSCREEN=1"
|
||||
# FULLSCREEN variable will have preference over other geometry variables.
|
||||
if [ -f "/sys/class/graphics/fb0/virtual_size" ]; then
|
||||
width="$(cut -d',' -f1 /sys/class/graphics/fb0/virtual_size)"
|
||||
heigth="$(cut -d',' -f2 /sys/class/graphics/fb0/virtual_size)"
|
||||
[ -n "${width}" ] && COG_ENV="${COG_ENV} COG_PLATFORM_WL_VIEW_WIDTH=${width}"
|
||||
[ -n "${heigth}" ] && COG_ENV="${COG_ENV} COG_PLATFORM_WL_VIEW_HEIGHT=${heigth}"
|
||||
fi
|
||||
fi
|
||||
|
||||
env ${COG_ENV} ${COG_BINARY} \
|
||||
--allow-file-access-from-file-urls=true \
|
||||
--allow-universal-access-from-file-urls=false \
|
||||
--enable-offline-web-application-cache=false \
|
||||
--enable-page-cache=false \
|
||||
--allow-modal-dialogs=true \
|
||||
/srv/www/index.html > /dev/null 2>&1 &
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop_process "${COG_BINARY}"
|
||||
stop_process "${DEMOSERVER_BINARY}"
|
||||
stop
|
||||
;;
|
||||
restart)
|
||||
$0 stop
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
[Unit]
|
||||
Description=Initialization of the ConnectCore demo example
|
||||
After=weston.service busybox-httpd.service
|
||||
Requires=weston.service
|
||||
After=busybox-httpd.service
|
||||
|
||||
# Make sure we are started after graphic service is available
|
||||
After=##WESTON_SERVICE##
|
||||
Requires=##WESTON_SERVICE##
|
||||
|
||||
[Service]
|
||||
Type=forking
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright (C) 2022 Digi International.
|
||||
# Copyright (C) 2022, 2023 Digi International.
|
||||
|
||||
require dey-examples-src.inc
|
||||
|
||||
|
|
@ -13,6 +13,14 @@ SRC_URI += " \
|
|||
file://connectcore-demo-example.service \
|
||||
"
|
||||
|
||||
WESTON_SERVICE ?= "weston.service"
|
||||
WESTON_SERVICE:ccmp15 ?= "weston-launch.service"
|
||||
|
||||
CC_DEMO_DISPLAY ?= "wayland-0"
|
||||
CC_DEMO_DISPLAY:ccmp15 ?= "wayland-1"
|
||||
CC_DEMO_ENV ?= "DISPLAY=:0.0 XDG_RUNTIME_DIR=/run/user/0 WAYLAND_DISPLAY=\${DEMO_DISPLAY}"
|
||||
CC_DEMO_ENV:ccimx6ul ?= ""
|
||||
|
||||
RDEPENDS:${PN} = " \
|
||||
busybox-httpd \
|
||||
libdigiapix-python3 \
|
||||
|
|
@ -30,22 +38,28 @@ 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/
|
||||
install -d ${D}/srv/www
|
||||
cp -r ${WORKDIR}/git/connectcore-demo-example/* ${D}/srv/www/
|
||||
|
||||
# Remove unused images
|
||||
find ${D}/srv/www/static/images/ -type f -name '*_board.png' -not -name '${MACHINE}_board.png' -delete
|
||||
# Remove unused images
|
||||
find ${D}/srv/www/static/images/ -type f -name '*_board.png' -not -name '${MACHINE}_board.png' -delete
|
||||
|
||||
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
|
||||
# Install systemd service
|
||||
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/
|
||||
sed -i -e "s,##WESTON_SERVICE##,${WESTON_SERVICE},g" \
|
||||
"${D}${systemd_unitdir}/system/connectcore-demo-example.service"
|
||||
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
|
||||
# Install connectcore-demo-example-init
|
||||
install -d ${D}${sysconfdir}/init.d/
|
||||
install -m 755 ${WORKDIR}/connectcore-demo-example-init ${D}${sysconfdir}/connectcore-demo-example
|
||||
sed -i -e "s@##CC_DEMO_ENV##@${CC_DEMO_ENV}@g" \
|
||||
-e "s@##CC_DEMO_DISPLAY##@${CC_DEMO_DISPLAY}@g" \
|
||||
"${D}${sysconfdir}/connectcore-demo-example"
|
||||
ln -sf ${sysconfdir}/connectcore-demo-example ${D}${sysconfdir}/init.d/connectcore-demo-example
|
||||
}
|
||||
|
||||
FILES:${PN} += " \
|
||||
|
|
|
|||
Loading…
Reference in New Issue