Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new makenode for sudowrt v0.3.0 (dispossessed) #30

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ ipks/
templateStaging/
settings.js
offlineConfig.json
log.txt
node_info.json
41 changes: 38 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,47 @@
NOTE: if using sudowrt-firmware v0.3.x (dispossessed), makenode is no longer necessary, but may be used in the event that you do not have access to a hardwired internet connection.

# For sudowrt-firmware v0.3.x
Typically, you should allow your home node it configure itself via the retrieve_ip/autoconf scripts that come pre-packaged in v0.3.0 and are run on first boot. However, if you would like to manually trigger configuration, you can use 'makenode.sh'.

## Install Dependencies
```
sudo apt update
sudo apt install curl jq
```

## Using NEW makenode
Connect via an ethernet cable to port 3 or 4 on a newly flashed home node.
Set the wired settings on your computer to:
```
IP: 172.22.0.9
SUBNET MASK: 255.255.255.0
GATEWAY: 0.0.0.0
```

If you do not already have an IP address on the mesh (that is one you've used before that you know will not conflict), just run,

```
./makenode.sh
```
This will request a new IP from our meshnode database and autoconfigure the node to use that IP on the mesh.

If you have an IP address that you are 100% is available, you can skip requesting an IP and just run the following,
```
ssh [email protected] '/opt/mesh/autoconf [desired_ip_address]'
```
Enter the default root password. Then reboot the node.

# For sudowrt-firmware v0.2.x

This is a node.js command line utility for configuring new sudo mesh nodes.

Early alpha status. Things may break.

# About
## About

makenode combines a set of configuration file templates with information like generated SSH keys, assigned IP address ranges, private wifi pasword, etc. then bundles the resulting configuration files into an ipk package, sends the ipk to the node using scp and installs the package. makenode can also optionally flash the node using the sudomesh firmware to prepare it for configuration.

# Install Dependencies
## Install Dependencies

```
sudo apt-get install dropbear
Expand All @@ -28,7 +63,7 @@ brew install fakeroot
xcode-select --install
```

# Using makenode
## Using makenode

First, clone the most recent stable release of makenode,
```
Expand Down
72 changes: 72 additions & 0 deletions makenode.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/bin/sh
# This script retrieves an IP address
# from a meshnode-database, running some version of
# https://github.com/sudomesh/meshnode-database
# Once an IP is retrieved, this script triggers
# the configuration of this node with the correct
# MESH IP and other related settings stored in
# /opt/mesh/autoconf

set -x
set -e

# default configs for People's Open Network
LOG="./log.txt"
JSON="./node_info.json"
MESHNODEDB="secrets.peoplesopen.net"
MESHNODEDB_IP="138.68.252.190"
USER="deployer"
PASS="praisebob"
POSTURL="https://$USER:$PASS@$MESHNODEDB/nodes"

echo "retrieving an IP address from" $MESHNODEDB >>$LOG

# check for internet connection for every every 10s
for i in 1 2 3 4 5;
do
if ping -q -c 1 -W 1 8.8.8.8 >/dev/null; then
echo "IPv4 is up" >>$LOG
break
else
echo "IPv4 is down" >>$LOG
fi
sleep 10
done

if ping -q -c 1 -W 1 google.com >/dev/null; then
echo "DNS is working" >>$LOG
else
echo "DNS is not working" >>$LOG
exit 1
fi

if ping -q -c 1 -W 1 $MESHNODEDB >/dev/null; then
echo $MESHNODEDB "is reachable" >>$LOG
else
echo $MESHNODEDB "is not reachable" >>$LOG
echo "trying by IP" $MESHNODEDB_IP >>$LOG
if ping -q -c 1 -W 1 $MESHNODEDB_IP >/dev/null; then
echo $MESHNODEDB_IP "is reachable" >>$LOG
else
echo $MESHNODEDB_IP "is not reachable" >>$LOG
exit 1
fi
fi

# make a post request to meshnode-databse
echo "posting to" $POSTURL >>$LOG
MESHNODE_DATA=$(curl -X POST -H "Content-Type: application/x-www-form-urlencoded" --data-urlencode data='{"type":"node"}' $POSTURL )

echo $MESHNODE_DATA > $JSON

# parse the json response
MESH_IP=$(jq -r '.data.mesh_addr_ipv4' $JSON)
MESH_GW=$(jq -r '.data.open_subnet_ipv4' $JSON)
MESH_MASK=$(jq -r '.data.open_subnet_ipv4_bitmask' $JSON)
echo "recieved mesh IP:" $MESH_IP >>$LOG
echo "recieved mesh block:" $MESH_GW"/"$MESH_MASK >>$LOG

# execute autoconf on home node
ssh [email protected] "/opt/mesh/autoconf $MESH_IP"

exit 0
1 change: 1 addition & 0 deletions node_info.json.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"status":"success","data":{"type":"node","mesh_addr_ipv4":"100.65.117.65","mesh_subnet_ipv4":"100.64.0.0","mesh_subnet_ipv4_mask":"255.192.0.0","mesh_subnet_ipv4_bitmask":"10","adhoc_addr_ipv4":"100.65.117.65","adhoc_subnet_ipv4_mask":"255.255.255.255","adhoc_subnet_ipv4_bitmask":"32","tun_addr_ipv4":"100.65.117.65","tun_subnet_ipv4_mask":"255.255.255.255","tun_subnet_ipv4_bitmask":"32","open_addr_ipv4":"100.65.117.65","open_subnet_ipv4":"100.65.117.64","open_subnet_ipv4_mask":"255.255.255.192","open_subnet_ipv4_bitmask":"26","open_dhcp_range_start":"95554","mesh_addr_ipv6":"a237:473:2389:a1:7ea3:a8d0:59aa:f617","id":"f9cc77f7-9135-4215-8511-14e273d4ffe4"}}