I am having some issues with automating tasks at boot on the Pi. I have tried numerous different methods to do this including the
systemd method and the
.bashrc method. The command is a simple one used to open chromium fullscreen and direct to a URL that acts as a ping board. I have no real use for a script as only one command is needed, the last lines of my
.bashrc read as so
if ! shopt -oq posix; then if [ -f /usr/share/bash-completion/bash_completion ]; then . /usr/share/bash-completion/bash_completion elif [ -f /etc/bash_completion ]; then . /etc/bash_completion fi fi chromium-browser --start-fullscreen preferred_URL &
Fairly simple command, opens the browser fullscreen and directs straight to the URL and the ampersand is there to keep the process from forking and I have tried it without. This is all well and good, and works fine as a command, but for some reason it does not work on boot. It will work when I open a terminal. which tells me the command is functional, but that is all. Because this method did not work I decided to try and put the command in to a script and run it on boot as a daemon service. So I created the service in the relevant location
/lib/systemd/system/Panel.service that reads as so;
[Unit] Description=Opens Chromium Browser and directs to PingBoard After=multi-user.target [Service] Type=idle ExecStart=/usr/bin/Panel.sh [Install] WantedBy=multi-user.target
And the script reads quite simply;
#!/bin/bash chromium-browser --start-fullscreen Required_URL & fi
And I run the commands as per the tutorial I was following:
sudo systemctl daemon-reload sudo systemctl enable Panel.service sudo chmod 644 /lib/systemd/system/Panel.service
Upon reboot the browser still does not launch and I am struggling to find out why, hence this post, I have seen quite a few posts on here about issues faced when doing these things and have tried the solutions to no avail, I have a feeling it is something very simple that I am overlooking. Please bear in mind that, although reasonably familiar with Linux, it is my 3rd day using a Pi and my very first time trying to automate a program via a command/script so please try not to make your answers too complex. Thanks in advance!
So I have since been informed of the
sudo journalctl -u Panel.service
Command which helped me gather more information on the issue, it said that there was a problem at line 5 which was the fi in the script, I removed this since, re-ran the relevant daemon commands and still no dice. I ran
journalctl command and got this output.
- Logs begin at Thu 2017-09-14 14:41:29 UTC, end at Thu 2017-09- 14 14:44:52 UTC. -- Sep 14 14:42:28 raspberrypi systemd: Started Opens Chromium Browser and directs to PingBoard. Sep 14 14:42:34 raspberrypi Panel.sh: [484:484:0914/144234.717436:ERROR:browser_main_loop.cc(582)] Failed to put Xlib into threaded mode. Sep 14 14:42:34 raspberrypi chromium-browse: cannot open display: Sep 14 14:42:34 raspberrypi systemd: Panel.service: Main process exited, code=exited, status=1/FAILURE Sep 14 14:42:34 raspberrypi systemd: Panel.service: Unit entered failed state. Sep 14 14:42:34 raspberrypi systemd: Panel.service: Failed with result 'exit-code'.
This issue has been solved. What I learned was that there was an autostart file within
/home/pi/.config/lxsession/LXDE-pi that read as so;
@lxpanel --profile LXDE-pi @pcmanfm --desktop --profile LXDE-pi @xscreensaver -no-splash @point-rpi
All I had to do was insert my command
@chromium-browser --start-fullscreen Required_URL just before the
@xscreensaver -no-splash line and Chromium starts at boot and directs to the relevant URL. The issue was caused by the fact that the command was previously being run before the GUI had initialised and therefore was not working correctly, this way the command is run after the GUI is initialised and works without issue. I am now to lengthen the script to automate login.
sudo journalctl -u Panel.service?