{"id":19007426,"url":"https://github.com/teschmitt/meshpi","last_synced_at":"2026-05-15T17:42:48.754Z","repository":{"id":133108597,"uuid":"488557825","full_name":"teschmitt/meshpi","owner":"teschmitt","description":"Build a batman-adv powered mesh network with Raspberry Pis from scratch","archived":false,"fork":false,"pushed_at":"2022-05-24T12:17:59.000Z","size":42,"stargazers_count":1,"open_issues_count":6,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-01T20:23:26.541Z","etag":null,"topics":["access-point","batman-adv","dtn7-rs","mesh","mesh-networks","raspberry-pi","raspberry-pi-os"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/teschmitt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-05-04T11:16:12.000Z","updated_at":"2024-01-29T08:47:28.000Z","dependencies_parsed_at":null,"dependency_job_id":"7c2a13cc-00c3-401a-bdb7-78a58ff4009a","html_url":"https://github.com/teschmitt/meshpi","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teschmitt%2Fmeshpi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teschmitt%2Fmeshpi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teschmitt%2Fmeshpi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teschmitt%2Fmeshpi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/teschmitt","download_url":"https://codeload.github.com/teschmitt/meshpi/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240035455,"owners_count":19737601,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["access-point","batman-adv","dtn7-rs","mesh","mesh-networks","raspberry-pi","raspberry-pi-os"],"created_at":"2024-11-08T18:38:22.054Z","updated_at":"2026-04-22T23:30:24.601Z","avatar_url":"https://github.com/teschmitt.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# UAVPi image build workflow\n\nWe'll be building two different images for this setup:\n\n1. A `node` image that can be flashed onto the devices that are participating only in the mesh network.\n2. An `ap` image that will be flashed to exactly one device which will act as the access points for devices wanting to connect to the mesh but that aren't part of the mesh.\n\nTaking care of steps 1 to 8 of the following prerequesites is required for both types of images/devices, step 9 is only for the `ap` image/device.\n\n\n## Prerequisites\nBuilding a deployable UAVPi image is aided by the scripts and pre-defined config files in this repository. There are a few prerequesites for starting this workflow:\n\n1. Download a suitable vanilla Raspi OS image, e.g. [2022-04-04-raspios-bullseye-armhf-lite](https://downloads.raspberrypi.org/raspios_lite_armhf/images/raspios_lite_armhf-2022-04-07/2022-04-04-raspios-bullseye-armhf-lite.img.xz)\n2. Flash that image to an SD card like so:\n\n```shell\n$ xzcat 2022-04-04-raspios-bullseye-armhf-lite.img.xz | sudo dd of=/dev/sdX bs=4M conv=fsync status=progress\n```\n\n3. Then clone this repository\n\n```shell\n$ git clone git@github.com:teschmitt/UAVPi.git\n$ cd UAVPi\n```\n\n4. Edit `pi_config/userconf_sample` in order to set up a custom default user. Generate the password hash with\n\n```shell\n$ openssl passwd -6\n   ... enter password ...\n```\n\nthen save the output to `pi_config/userconf`:\n\n```\n\u003cusername\u003e:\u003cPASSWORDHASH\u003e\n```\n\n5. The self-hosted setup steps require a wifi connection, so edit `wpa_supplicant.conf_sample` and remove the suffix (remember to wipe all sensitive info from this before creating and distributing the image).\n6. If you want to connect to the Pi via SSH, remove the suffix from `ssh_sample`. These will be copied to the `boot` partition and will be read out automagically on the Pi's first startup.\n7. `./setup_medium.sh` expects the DTN7 binaries (from the [Rust implementation](https://github.com/dtn7/dtn7-rs)) to be in a sub-directory called `dtn7-rs-release`. So please compile them with `cross build --release --target arm-unknown-linux-gnueabi` and place them there.\n8. Go and tell the `cross` maintainers what absolute MVPs they are. I'll wait.\n\nImportant: the following step only has to be performed when creating an `ap` image:\n\n9. Edit `networking/hostapd.conf` to reflect the settings you want for the non-mesh connecting clients. Also take a good hard look at `setup_mesh.sh` starting at around line 70, where settings are getting written to `dnsmasq.conf` and `dchpcd.conf`.\n\nThe above steps will normally only have to be done once, then you have a working environment for the following workflow.\n\n\n\n## Image Creation\n\nIf everything went well, you should have two partitions mounted and it should look something like this:\n\n```shell\n$ lsblk\n...\nsdX      8:16   1  59,5G  0 disk\n├─sdX1   8:17   1   256M  0 part /run/media/\u003cusername\u003e/boot\n└─sdX2   8:18   1   1,7G  0 part /run/media/\u003cusername\u003e/rootfs\n```\n\nYou can then launch the script to copy all files needed for the self-hosted setup with the details from above:\n\n```shell\n$ ./setup_medium.sh --bootfs /run/media/\u003cusername\u003e/boot --rootfs /run/media/\u003cusername\u003e/rootfs\n```\n\nSince we're copying the DTN7 stuff into system directories, you will need to plug in your root password along the way. Don't forget to `umount` the partitions. You can now boot up the Pi (and connect to it via ssh, if you provided the adequate credentials above).\n\n\n\n### Creating a `node` Image\n\nFor the `ap` image, see below.\n\nIn order to install all needed software, run\n\n```shell\n$ ./setup_host.sh\n```\n\nThis requires an internet connection and may take a while. When it's done you should see\n\n```\nSetup finished, you can now run the setup_mesh.sh script.\n```\n\nSo do that:\n\n```shell\n$ ./setup_mesh.sh\n```\n\nThis will actually muck around in the network configurations and set up all interfaces needed by `batman-adv`. If you want to change any of the used options, check the `networking` directory for the appropriate files.\n\n\n\n### Creating an `ap` Image\n\nThis is largely analog to the `node` image, but we need to set a flag in the setup scripts to tell them to add additional software, configs, and so on. So here we go:\n\nInstall all software:\n\n```shell\n$ ./setup_host.sh --ap-mode\n```\n\nThis requires an internet connection and may take a while. When it's done you should see\n\n```\nSetup finished, you can now run the setup_mesh.sh script.\n```\n\nSo do that:\n\n```shell\n$ ./setup_mesh.sh --ap-mode\n```\n\n\n\n## Create and shrink an image\n\nNow for the most important part, creating the image:\n\n1. Power down the Pi and remove the SD card. Mount it on the workstation\n2. Find out the device ID like above\n3. Wipe any sensitive information (e.g. login info to your Wifi in `\u003cpath_to_rootfs\u003e/etc/wpa_supplicant/wpa_supplicant.conf`) you don't want to distribute later on from the SD card data.\n4. Fire up the `create_image.sh` script (this will also require your `sudo` credentials, so have those handy):\n\n```shell\n$ ./create_image.sh /dev/sdX imagename.img\n```\n\nIt is advisable to do this once for an `ap` image and once for a `node` image. This will take a while, but you'll have a ready to deploy image when it's done.\n\n\n\n## On hostnames\nThe `setup_mesh.sh` script will generate a hostname based on the MAC address of the `wlan0` interface and write this hostname to `/etc/hosts` and `/etc/hostname`. The image you create will have this hostname hard-coded into it. If you want something more generic you will have to alter the appropriate files before ripping the image.\n\nTo auto-generate and set a hostname with the schema `uav-\u003clast 6 MAC addr digits w/o colons\u003e`, simply run the `autogen_hostname.sh` script.\n\n\n## Deploying the Images\n\nLet's say we have two images from the above setup workflow:\n\n1. meshpi-node.img\n2. meshpi-ap.img\n\nWe can now flash these images to SD cards as we need them and they'll work. On first boot, make sure to run the `autogen_hostname.sh` script to give the devices unique hostnames.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteschmitt%2Fmeshpi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fteschmitt%2Fmeshpi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteschmitt%2Fmeshpi/lists"}