Yocto startup scripts systemd: Difference between revisions
From embeddedTS Manuals
No edit summary |
(Minor fixups) |
||
Line 1: | Line 1: | ||
To have | To have a custom headless application start up at boot, a systemd service needs to be created. Create the file /etc/systemd/system/yourapp.service with contents similar to below: | ||
<source lang=ini> | <source lang=ini> | ||
[Unit] | [Unit] | ||
Line 12: | Line 12: | ||
</source> | </source> | ||
If you depend on networking you should add "After=network.target" in the Unit section. Once | If you depend on networking you should add "After=network.target" in the Unit section. Once this file is in place, it cab be added to automatic startup with the following: | ||
<source lang=bash> | <source lang=bash> | ||
Line 24: | Line 24: | ||
{{Note|See the [http://www.freedesktop.org/software/systemd/man/systemd.service.html systemd documentation] for in depth documentation on services.}} | {{Note|See the [http://www.freedesktop.org/software/systemd/man/systemd.service.html systemd documentation] for in depth documentation on services.}} | ||
To | To set up a graphical application startup, change the file: | ||
/usr/bin/mini-x-session | /usr/bin/mini-x-session | ||
At the end of the script replace matchbox-terminal with your application: | At the end of the script replace "matchbox-terminal" with your application (absolute path may need to be specified): | ||
<source lang=bash> | <source lang=bash> | ||
matchbox-terminal& | matchbox-terminal& | ||
exec matchbox-window-manager | exec matchbox-window-manager | ||
</source> | </source> | ||
The exec statement must be last in the script in order to take over this script's PID for correct operation. |
Revision as of 13:30, 25 July 2017
To have a custom headless application start up at boot, a systemd service needs to be created. Create the file /etc/systemd/system/yourapp.service with contents similar to below:
[Unit]
Description=Run an application on the i.MX6
[Service]
Type=simple
ExecStart=/usr/local/bin/your_app_or_script
[Install]
WantedBy=multi-user.target
If you depend on networking you should add "After=network.target" in the Unit section. Once this file is in place, it cab be added to automatic startup with the following:
# Start your app on bootup, but will not start it now
systemctl enable yourapp.service
# Start your app now, but doesn't change auto startup
systemctl start yourapp.service
Note: | See the systemd documentation for in depth documentation on services. |
To set up a graphical application startup, change the file: /usr/bin/mini-x-session
At the end of the script replace "matchbox-terminal" with your application (absolute path may need to be specified):
matchbox-terminal&
exec matchbox-window-manager
The exec statement must be last in the script in order to take over this script's PID for correct operation.