NervesBackdoor View Source

Setup and Maintenance Tools with RESTish API:

  • Network setup (eth0)
  • Device discovery (UDP broadcast)
  • Database backup and restore
  • Password reset (thru file upload)

API

curl http://nerves.local:31680/ping
curl http://nerves.local:31680/data/$DB.db3 --output /tmp/$DB.db3
curl -F 'file=@/tmp/$DB.db3' http://nerves.local:31680/upload?path=/data/$DB.db3
curl http://nerves.local:31680/net/state/eth0
curl http://nerves.local:31680/net/setup/eth0 -H "Content-Type: application/json" -X POST -d '{"method":"dhcp"}'
curl http://nerves.local:31680/net/setup/eth0 -H "Content-Type: application/json" -X POST -d '{"method":"static", "address":"10.77.4.100", "prefix_length":8, "gateway":"10.77.0.1", "name_servers":["10.77.0.1"]}'
curl http://nerves.local:31680/app/start/$APP
curl http://nerves.local:31680/app/stop/$APP

Helpers

mix run discover.exs --no-start
NervesBackdoor.mac
NervesBackdoor.ifname
NervesBackdoor.password
NervesBackdoor.pass_set ""
NervesBackdoor.pass_reset
Application.started_applications
Application.loaded_applications
Application.get_all_env :nerves_backdoor
ls "/data"
VintageNet.info
VintageNet.get_configuration("eth0")
VintageNet.get(["interface", "eth0", "type"])
VintageNet.get(["interface", "eth0", "state"])
VintageNet.get(["interface", "eth0", "connection"])
VintageNet.configure("eth0", %{type: VintageNetEthernet, ipv4: %{method: :dhcp}})
VintageNet.configure("eth0", %{type: VintageNetEthernet, ipv4: %{method: :static, address: "10.77.4.100", prefix_length: 8, gateway: "10.77.0.1", name_servers: ["10.77.0.1"]}})

Installation

Install into nerves project as described at https://hexdocs.pm/nerves/user-interfaces.html

If available in Hex, the package can be installed by adding nerves_backdoor to your list of dependencies in mix.exs:

def deps do
  [
    {:nerves_backdoor, "~> 0.1.0"}
  ]
end

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/nerves_backdoor.

Research

  • Restrict cowboy listener to usb0 interface
  • Restrict discovery broadcast to eth0
  • VintageNet unrecoverable ETS error after setting invalid config
  • Customize and broadcast nerves-% hostname