End Product Application


Warning

For a lot of reasons, the end product application should never run as the root user. A specific user and group “apps” has been created and granted necessary access to use the required system resources.

Important

ALL files related to the end product application must be located in /data.

Please see the discussion of the /data layout here.

As noted in the data filesystem paths table, there are several directories under /data for the installation of the end product application executable(s) as well as configuration files and multimedia resources. Hopefully, the descriptions of the intended directory contents are self-explanatory.

Perhaps the most challenging task of end product application installation is the creation of a proper /data/sbin/run_application script. This script will be launched by the user_app init script with the “apps” effective user id.

Important

Do not modify the /etc/init.d/user_app script.

All end product application specific startup and shutdown code must be in /data/sbin/run_application.

The run_application Script

As explained here you must create a run_application script to launched your end product application and disable or remove the existing run_demos script in /data/sbin.

1# change to /data/sbin
2root@imx6dl-g3-sd:~# cd /data/sbin
3
4# to disable the run_demos script
5root@imx6dl-g3-sd:/data/sbin# chmod -x run_demos
6
7# or, to remove the run_demos script
8root@imx6dl-g3-sd:/data/sbin# rm -f run_demos

The following code block shows a sample run_application script. Do not forget to make it executable!

 1#!/bin/sh
 2
 3# sample run_application script
 4
 5APP="foo-viewer"
 6
 7# DO NOT change XDG_RUNTIME_DIR; it is set up by /etc/init.d/user_app
 8# before it uses su to execute this script as the "apps" user
 9export XDG_RUNTIME_DIR=/var/run/user_app
10PID_FILE=${XDG_RUNTIME_DIR}/${APP}.pid
11APP_EXE="/data/bin/${APP}"
12
13# use this var to pass args to your app
14# DO NOT put "-platform eglfs -plugin tslib" here!!!
15# It **will** break TS input on some screens
16APP_ARGS=""
17
18source /etc/profile.d/tslib.sh
19# NOTE: the following script has **all** env vars needed for proper Qt operation
20#       DO NOT add Qt env vars here!!!
21source /etc/profile.d/qt-eglfs.sh
22
23start() {
24    start-stop-daemon -b -S -q -m -p ${PID_FILE} --exec $APP_EXE -- $APP_ARGS
25}
26
27stop() {
28    start-stop-daemon -s QUIT -K -q -p ${PID_FILE}
29}
30
31case "$1" in
32    start)
33        start
34        ;;
35    stop)
36        stop
37        ;;
38    *)
39        echo "Usage: $0 {start|stop}"
40        exit 1
41esac
42
43exit $?