0

I want to fire 2 commands on startup on my raspberry pi

The first one runs a node server starting script. The second one should open chromium browser with a specific page.

The point is that I want to wait a couple of seconds to launch chromium so I'm sure that the webpage will be connected to the node server.

I tried so many things but I can't seem to fix a the delay.

Any suggestions?

This is what I have now in an LXDE session:

@lxpanel --profile LXDE-pi
@pcmanfm --desktop --profile LXDE-pi
@xscreensaver -no-splash

// This starts the node server
@/home/pi/autostart.sh

// This starts the browser
@/home/pi/async.sh

The async bash runs this:

#!/usr/bin/env bash
sleep 5
chromium-browser -kiosk http://localhost:3000

1 Answers1

0

You start the node server and loop until the site comes online before launching the web-browser.
Replace "sleep 5" in async.sh by the following:

until $(curl --output /dev/null --silent --head --fail http://localhost:3000); do
    printf '.'
    sleep 1
done

source : How to create a loop in bash that is waiting for a webserver to respond?

HungryFoolish
  • 542
  • 1
  • 9
  • 27