Jessie Startup Scripts: Difference between revisions
(Created page with "To have your headless application start up on poweron you need to create a service. Create a file in /etc/systemd/system/yourapp.service <source lang=ini> [Unit] Description=...") |
No edit summary |
||
Line 1: | Line 1: | ||
A systemd service can be created to start up headless applications. Create a file in /etc/systemd/system/yourapp.service | |||
<source lang=ini> | <source lang=ini> | ||
[Unit] | [Unit] | ||
Line 12: | Line 12: | ||
</source> | </source> | ||
If | If networking is a dependency add "After=network.target" in the Unit section. Once you have this file in place add it to startup with: | ||
<source lang=bash> | <source lang=bash> | ||
# Start | # Start the app on startup, but will not start it now | ||
systemctl enable yourapp.service | systemctl enable yourapp.service | ||
# Start | # Start the app now, but doesn't change auto startup | ||
systemctl start yourapp.service | systemctl start yourapp.service | ||
</source> | </source> | ||
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 start an application on bootup with X11 instead change the x-session-manager. By default the system starts xfce: | ||
<source lang=bash> | <source lang=bash> | ||
root@ts:~# ls -lah /usr/bin/x-session-manager | root@ts:~# ls -lah /usr/bin/x-session-manager | ||
Line 32: | Line 32: | ||
</source> | </source> | ||
The x-session can be modified to only start specified processes. Create the file /usr/bin/mini-x-session with these contents: | |||
<source lang=bash> | <source lang=bash> | ||
#!/bin/bash | #!/bin/bash | ||
Line 48: | Line 48: | ||
</source> | </source> | ||
If the x-session-manager process ever closes x11 will restart. The exec command allows a new process to take over the existing PID. In the above example xfce4-terminal takes over the PID of x-session-manager. If the terminal is closed with commands like exit the slim/x11 processes will restart. |
Latest revision as of 15:43, 10 February 2017
A systemd service can be created to start up headless applications. Create a file in /etc/systemd/system/yourapp.service
[Unit]
Description=Run an application on startup
[Service]
Type=simple
ExecStart=/usr/local/bin/your_app_or_script
[Install]
WantedBy=multi-user.target
If networking is a dependency add "After=network.target" in the Unit section. Once you have this file in place add it to startup with:
# Start the app on startup, but will not start it now
systemctl enable yourapp.service
# Start the app now, but doesn't change auto startup
systemctl start yourapp.service
Note: | See the systemd documentation for in depth documentation on services. |
To start an application on bootup with X11 instead change the x-session-manager. By default the system starts xfce:
root@ts:~# ls -lah /usr/bin/x-session-manager
lrwxrwxrwx 1 root root 35 May 26 2015 /usr/bin/x-session-manager -> /etc/alternatives/x-session-manager
root@ts:~# ls -lah /etc/alternatives/x-session-manager
lrwxrwxrwx 1 root root 19 May 26 2015 /etc/alternatives/x-session-manager -> /usr/bin/startxfce4
The x-session can be modified to only start specified processes. Create the file /usr/bin/mini-x-session with these contents:
#!/bin/bash
matchbox-window-manager -use_titlebar no &
exec xfce4-terminal
You may need to "apt-get install matchbox-window-manager." first. This is a tiny window manager which also has a few flags that simplify embedded use. Now enable this session manager and restart slim to restart x11 and show it now.
chmod a+x /usr/bin/mini-x-session
rm /etc/alternatives/x-session-manager
ln -s /usr/bin/mini-x-session /etc/alternatives/x-session-manager
service slim restart
If the x-session-manager process ever closes x11 will restart. The exec command allows a new process to take over the existing PID. In the above example xfce4-terminal takes over the PID of x-session-manager. If the terminal is closed with commands like exit the slim/x11 processes will restart.