How to autostart application with systemd
Example for creating Qt application autostart on TQMa6x BSP
1.Create file /etc/systemd/qtdemo.service
with following content:
[UNIT] Description=Start Multitouch Qt Demo [SERVICE] [Install] WantedBy=multi-user.target
2.Create file /lib/systemd/system/demo.service
with following content:
[Unit] After=multi-user.target Description=start Qt demo [Service] Type=forking RemainAfterExit=no ExecStart=/lib/systemd/systemd-demo start ExecStop=/lib/systemd/systemd-demo stop [Install] WantedBy=multi-user.target.wants
3. Create file /lib/systemd/systemd-demo
with following content:
#!/bin/sh # launch demo application # export QWS_MOUSE_PROTO=tslib:/dev/input/event1 export TSLIB_TSDEVICE=/dev/input/event1 DEMO_PATH=/usr/bin/qwt-6.0.1 DEMO_EXEC=oscilloscope DEMO_OPTS=-qws case "$1" in start) echo 0 > /sys/class/graphics/fbcon/cursor_blink echo 0 > /sys/class/graphics/fbr0/blank /bin/mount -o remount,rw / /usr/bin/ts_calibrate /bin/mount -o remount,ro / ${DEMO_PATH}/${DEMO_EXEC} ${DEMO_OPTS} & ;; stop) killall ${DEMO_EXEC} ;; *) echo "Usage: $0 {start|stop}" exit 1 ;; esac exit 0
4. make /lib/systemd/systemd-demo
executable.
5. create symlink demo.service
in /etc/system/system/multi-user.target.wants
that points to the file /lib/systemd/system/demo.service
:
cd /etc/systemd/system/multi-user.target.wants/ ln -s /lib/systemd/system/demo.service demo.service
Disclaimer
TQ-Systems GmbH provides the Board Support Packages (BSP) free of charge. The software included in the shipment has been configured individually for the starter kits. The software is only intended to evaluate the module. The use of the Board Support Packages (BSP) is only allowed within the scope of functionality described by TQ-Systems GmbH. TQ-Systems GmbH does not accept any liability for all further changes of the Board Support Package and for any damage resulting from its use.
TQ-Systems GmbH provides the Board Support Packages (BSP) free of charge. The software included in the shipment has been configured individually for the starter kits. The software is only intended to evaluate the module. The use of the Board Support Packages (BSP) is only allowed within the scope of functionality described by TQ-Systems GmbH. TQ-Systems GmbH does not accept any liability for all further changes of the Board Support Package and for any damage resulting from its use.