0

This is what i got with

systemctl status rc-local.service
- déc. 07 16:09:48 PKPIE01 rc.local[2157]: No protocol specified
- déc. 07 16:09:48 PKPIE01 rc.local[2157]: Error: Can't open display: (null)
- déc. 07 16:09:48 PKPIE01 rc.local[2157]: Failed creating new xdo instance
- déc. 07 16:09:48 PKPIE01 sudo[2161]:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/usr/bin/firefox -url "theurl"
- déc. 07 16:09:48 PKPIE01 sudo[2161]: pam_unix(sudo:session): session opened for user root by (uid=0)
- déc. 07 16:09:48 PKPIE01 rc.local[2157]: No protocol specified
- déc. 07 16:09:48 PKPIE01 rc.local[2157]: Failed to connect to Mir: Failed to connect to server socket: Aucun fichier ou dossier de ce type
- déc. 07 16:09:48 PKPIE01 rc.local[2157]: Unable to init server: Impossible de se connecter : Connexion refusée
- déc. 07 16:09:48 PKPIE01 rc.local[2157]: Error: cannot open display: :0.0
- déc. 07 16:09:48 PKPIE01 sudo[2161]: pam_unix(sudo:session): session closed for user root

And this is what i execute in my /etc/rc.local working when I run

sudo /etc/rc.local 

in terminal but doesn't work at restart :

sleep 45s

export DISPLAY=:0.0 xdotool

export DISPLAY=:0.0 firefox

sudo /usr/bin/firefox -url "the url"

exit 0

Any clues ? I'm really new to this, so if you have any good advices or best practices, let me know !

derHugo
  • 3,356
  • 5
  • 31
  • 51
Kyl'
  • 1
  • 1
  • 2
  • That sounds like a terrible idea - IMHO you should be using your desktop session's startup applications. See for example How do run a program at startup? – steeldriver Dec 07 '17 at 15:27
  • It's not what i want to do actually – Kyl' Dec 07 '17 at 15:29
  • 1
    sudo is not applicable in rc.local. – chili555 Dec 07 '17 at 15:45
  • XY Problem. We cannot help you more until you explain what you are trying to accomplish (since you say you don't want to launch Firefox). Whatever it is, @steeldriver is right - rc.local is the wrong tool for the job. – user535733 Dec 07 '17 at 17:35
  • I want to launch firefox in full screen at startup on a distant machine on a specific url, it works when i launch rc.local on hand but not when the machine is booting.

    I forgot to put my xdotool line there, but it's present in my rc.local

    – Kyl' Dec 08 '17 at 06:14

2 Answers2

0

If you VNC in, you can run the script/command "locally".

As mentioned by steeldriver (Rc.Local works manually but not at boot) and Sergiy Kolodyazhnyy (https://askubuntu.com/a/984164/877732) this doesn't work, but I'm sure it worked once???

I created a bash script, nano startFirefox.sh:

#!/bin/bash
echo "Starting Firefox"
/usr/lib/firefox-esr/firefox-esr &

Made it executable chmod a+x startFirefox.sh (https://stackoverflow.com/a/8352939/5165135)

Added it to /etc/rc.local:

fi
/home/pi/startFirefox.sh &
exit 0

On newer systems, check it is running systemctl status rc-local.service (https://askubuntu.com/a/759821/877732)

0
  1. Don't run GUI apps via rc.local, it's a command-line only script.

  2. All your commands are blocking, append & at the end of each line

  3. sudo is redundant, because rc.local runs as root already

Sergiy Kolodyazhnyy
  • 105,154
  • 20
  • 279
  • 497