### Start Erlang Distribution Source: https://hexdocs.pm/nerves_pack/nerves_pack Steps to start an Erlang distribution node on a Nerves device. This involves starting the epmd daemon, starting the Erlang node with a specific name, and setting a distribution cookie for secure communication. ```elixir iex> System.cmd("epmd", ["-daemon"]) {"", 0} iex> Node.start(:"nerves@nerves.local") {:ok, #PID<0.26318.2>} iex(nerves@nerves.local)> Node.set_cookie(:my_secret_cookie) true ``` -------------------------------- ### Install Nerves Pack Dependency Source: https://hexdocs.pm/nerves_pack/readme Add the nerves_pack dependency to your project's `mix.exs` file to include its services. ```elixir def deps do [ {:nerves_pack, "~> 0.4.1"} ] end ``` -------------------------------- ### Configure Shoehorn for NervesPack Startup Source: https://hexdocs.pm/nerves_pack/nerves_pack Configures the `shoehorn` application to start `nerves_runtime` and `nerves_pack` services separately. This ensures access to the device even if the main application fails. ```elixir config :shoehorn, init: [:nerves_runtime, :nerves_pack], app: Mix.Project.config()[:app] ``` -------------------------------- ### Example Remote Shell Interaction Source: https://hexdocs.pm/nerves_pack/readme Demonstrates interacting with a Nerves device from a remote Elixir shell, including importing modules and accessing system information. ```elixir iex(nerves@nerves.local)> use Toolshed Toolshed imported. Run h(Toolshed) for more info :ok iex(nerves@nerves.local)> cat "/proc/cpuinfo" processor : 0 model name : ARMv6-compatible processor rev 7 (v6l) BogoMIPS : 697.95 Features : half thumb fastmult vfp edsp java tls CPU implementer : 0x41 CPU architecture: 7 CPU variant : 0x0 CPU part : 0xb76 CPU revision : 7 Hardware : BCM2835 Revision : 9000c1 Serial : 00000000b27aa712 Model : Raspberry Pi Zero W Rev 1.1 ``` -------------------------------- ### Nerves Pack Networking and System Configuration Source: https://hexdocs.pm/nerves_pack/changelog Details changes related to network configuration, WiFi setup, and other system-level enhancements provided by nerves_pack, such as mDNS and automatic network setup. ```APIDOC Networking and System Configuration: - **Automatic Network Configuration Removal (v0.3.2)**: Automatic network configuration was removed to prevent interference with predictable networking and to allow permanent deconfiguration of network interfaces. - **WiFi Wizard (v0.3.0, v0.2.1, v0.2.0)**: The `vintage_net_wizard` setup helper was removed in v0.3.0. In v0.2.1, it became optional. In v0.2.0, `WiFiWizardButton` became opt-in to allow `NervesPack` to work with more systems. - **mDNS Configuration (v0.1.1)**: Updates to `mdns_lite` allow mDNS host and services to be configured at runtime, providing basic defaults when no other options are set. `VintageNetMonitor` integration ensures faster mDNS response times by updating records on address changes. - **Nerves System Minimums**: Version v0.7.0 bumped minimum requirements to Elixir >= 1.10 and OTP >= 23. Version v0.6.0 bumped the minimum Elixir to 1.9. ``` -------------------------------- ### Start Erlang Distribution Source: https://hexdocs.pm/nerves_pack/readme Steps to start the Erlang Port Mapper Daemon (epmd) and a new Erlang node on a Nerves device. This enables distributed Erlang/Elixir communication. ```elixir iex> System.cmd("epmd", ["-daemon"]) {"", 0} iex> Node.start(internet_name("nerves@nerves.local")) {:ok, #PID<0.26318.2>} iex(nerves@nerves.local)> Node.set_cookie(:my_secret_cookie) true ``` -------------------------------- ### Configure Shoehorn for Nerves Pack Source: https://hexdocs.pm/nerves_pack/readme Configure the `shoehorn` application to start `nerves_runtime` and `nerves_pack` services separately, ensuring access even if the main application fails. ```elixir config :shoehorn, init: [:nerves_runtime, :nerves_pack], app: Mix.Project.config()[:app] ``` -------------------------------- ### Install nerves_pack Dependency Source: https://hexdocs.pm/nerves_pack/nerves_pack Adds the nerves_pack dependency to your Elixir project's `mix.exs` file. This automatically includes networking, mDNS, SSH, and other services. ```elixir def deps do [ {:nerves_pack, "~> 0.4.1"} ] end ``` -------------------------------- ### Configure mDNS Lite for Nerves Devices Source: https://hexdocs.pm/nerves_pack/nerves_pack Sets up `mdns_lite` to advertise services for Nerves devices on a local network. It configures hostnames like `nerves.local` and specific device hostnames, along with essential services like SSH and epmd. ```elixir config :mdns_lite, # The `host` key specifies what hostnames mdns_lite advertises. # `:hostname` advertises the device's hostname.local. # For the official Nerves systems, this is "nerves-<4 digit serial#>.local". # mdns_lite also advertises "nerves.local" for convenience. # If more than one Nerves device is on the network, delete "nerves" from the list. host: [:hostname, "nerves"], ttl: 120, # Advertise the following services over mDNS. services: [ %{protocol: "ssh", transport: "tcp", port: 22}, %{protocol: "sftp-ssh", transport: "tcp", port: 22}, %{protocol: "epmd", transport: "tcp", port: 4369} ] ``` -------------------------------- ### Configure mDNS for Nerves Devices Source: https://hexdocs.pm/nerves_pack/readme Configure `mdns_lite` to advertise services like SSH and SFTP, allowing devices to be found on the LAN via hostnames like `nerves.local` or `nerves-.local`. ```elixir config :mdns_lite, host: [:hostname, "nerves"], ttl: 120, services: [ %{protocol: "ssh", transport: "tcp", port: 22}, %{protocol: "sftp-ssh", transport: "tcp", port: 22}, %{protocol: "epmd", transport: "tcp", port: 4369} ] ``` -------------------------------- ### Nerves Pack SSH Support Evolution Source: https://hexdocs.pm/nerves_pack/changelog Tracks the evolution of SSH support within nerves_pack, including refactoring into a dedicated library, changes in firmware update mechanisms, and configuration of the SSH daemon. ```APIDOC SSH Support Enhancements and Changes: - **Refactoring to nerves_ssh (v0.4.0)**: SSH support was refactored into a separate library, `nerves_ssh`, to improve maintainability and allow projects not using `nerves_pack` to leverage SSH features. This also introduced improvements to SSH support. - **Firmware Updates via SSH Subsystem (v0.4.0)**: A significant change involved moving firmware updates from port 8989 to an SSH subsystem on port 22. This is a breaking change for scripts relying on the old port. Refer to the `nerves_ssh` upgrade guide for details. - **SSH Daemon Supervision (v0.2.2)**: The `sshd` process is now supervised, and its listening port can be configured. - **SSH Daemon IPv6 Support (v0.3.2)**: The SSH daemon was updated to start with `inet6` support, enabling IPv6 connectivity. ``` -------------------------------- ### Connect via SSH Source: https://hexdocs.pm/nerves_pack/nerves_pack Connect to a Nerves device using SSH. The default hostname is nerves.local. If mDNS is not working, use the device's IP address. ```bash ssh nerves.local ``` -------------------------------- ### Nerves SSH Configuration Source: https://hexdocs.pm/nerves_pack/readme Configuration snippet for nerves_ssh, typically found in config.exs. It includes settings for SSH public keys to allow secure login. ```elixir config :nerves_ssh, ssh_private_key: "~/.ssh/id_rsa" ``` -------------------------------- ### Connect to Remote Erlang Node Source: https://hexdocs.pm/nerves_pack/nerves_pack Connect to a Nerves device's Erlang node from your computer using IEx. This requires specifying the local name, cookie, and the remote node name. It also shows how to run commands on the remote device. ```bash $ iex --name me@0.0.0.0 --cookie my_secret_cookie --remsh nerves@nerves.local Erlang/OTP 22 [erts-10.6.4] [source] [64-bit] [smp:32:32] [ds:32:32:10] [async-threads:1] [hipe] Interactive Elixir (1.9.4) - press Ctrl+C to exit (type h() ENTER for help) iex(nerves@nerves.local)1> use Toolshed Toolshed imported. Run h(Toolshed) for more info :ok iex(nerves@nerves.local)2> cat "/proc/cpuinfo" processor : 0 model name : ARMv6-compatible processor rev 7 (v6l) BogoMIPS : 697.95 Features : half thumb fastmult vfp edsp java tls CPU implementer : 0x41 CPU architecture: 7 CPU variant : 0x0 CPU part : 0xb76 CPU revision : 7 Hardware : BCM2835 Revision : 9000c1 Serial : 00000000b27aa712 Model : Raspberry Pi Zero W Rev 1.1 iex(nerves@nerves.local)6> ``` -------------------------------- ### Nerves Pack Dependency Management Source: https://hexdocs.pm/nerves_pack/changelog Details changes and updates to core dependencies used by nerves_pack, such as vintage_net, mdns_lite, and nerves_ssh. This section highlights version compatibility and breaking changes introduced in dependencies. ```APIDOC Dependency Updates and Management: - **vintage_net**: Updates include support for v0.7.0 (splitting networking technologies), v0.9.0 (potential breaking changes for custom tech), and v0.10.0. Users updating vintage_net should consult its changelog for specific details. - **mdns_lite**: Updates to v0.6.1 and later versions enable runtime configuration of mDNS host and services, and integrate with VintageNetMonitor for faster mDNS record updates. - **nerves_ssh**: Introduced as a standalone library to refactor SSH support, moving away from embedded code in nerves_pack. This includes improvements and easier maintenance for SSH functionality. - **vintage_net_wizard**: Removed as a setup helper in v0.3.0, with users directed to its own documentation for configuration. It was later made optional in v0.2.1. - **nerves_motd**: Added as a dependency in v0.5.0 to facilitate easy addition of login greetings. - **busybox**: Removed as a direct dependency in v0.2.1, as it is now included in Nerves systems. - **Dependency Constraints**: In v0.7.1, all explicit dependency constraints were removed, delegating constraint management entirely to the referenced libraries. ``` -------------------------------- ### Connect to Remote Erlang Node Source: https://hexdocs.pm/nerves_pack/readme Connect to a remote Erlang node from your computer using the iex shell. Requires specifying the node name, cookie, and the remote node's address. ```shell $ iex --name me@0.0.0.0 --cookie my_secret_cookie --remsh nerves@nerves.local ``` -------------------------------- ### Connect via SSH Source: https://hexdocs.pm/nerves_pack/readme Connect to a Nerves device using SSH. The default hostname is nerves.local, which may need to be replaced with the device's IP address if mDNS is not working. ```shell ssh nerves.local ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.