Skip to content

Boot sequence, init, captive portal, and recovery

Igor edited this page Jul 29, 2017 · 1 revision

How boot sequence runs

  1. Make RasPi calling your own startup script. In /etc/rc.local:

nohup /home/pi/Orchids/init.sh &

  1. In /home/pi/Orchids/init.sh:
  • Detect WiFi SSID set or got already an IP by DHCP.
  • If no SSID and no IP then activate Captive portal => Call captive script and exit.
  • From here normal boot continues:
    • Kill all uncontrolled ssh sessions if any, including remaining of recovery script.
    • Call reverse HTTP and reverse SSH recovery script.

How Captive script works

Purpose:

Configure RasPi with SSID and password of your WiFi. Advanced purpose: set static IP for WLAN or for LAN interface.

Principle:

  • Switch the RasPi into AP mode with known SSID (OrchidCareAP, for instance) and with no password (for simplicity).
  • Optional: Run HTTP server and Captive portal page with SSID and passphrase fields (at least).
  • Accept SSH (or optional HTTP) connections in order to configure your WiFi SSID + passphrase.
  • Once configured, propose user to reboot the RasPi. Automatic reboot may cause problems and recommended to be supervised by user.

How Recovery script works

Purpose:

Make sure the connection from VPS to RasPi works. If not then recover it. RasPI <--ReverseSSH/HTTP--> VPS <--SSH/HTTP--> User

Principle (similar for HTTP and SSH):

  • Access VPS from RasPi to VPS.
  • Try to get relevant info from RasPi: curl or SSH to appropriate reversed port (10080 or 10022).
  • Count failures.
  • If exceeded count limit then kill all reverse tunnel processes and try to establish new ones and reset the counter.