Skip to content

Instantly share code, notes, and snippets.

@bladedoyle
Last active November 16, 2017 12:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bladedoyle/4b1b513ec1001bb2cf5d26e485f8aef8 to your computer and use it in GitHub Desktop.
Save bladedoyle/4b1b513ec1001bb2cf5d26e485f8aef8 to your computer and use it in GitHub Desktop.
Configure and Run an OpenBazaar 2.0 Server on a Raspberry Pi

Download the image, and write it to a micro-sd

Reference: https://downloads.raspberrypi.org/raspbian_latest.torrent

Reference: https://www.raspberrypi.org/documentation/installation/installing-images/README.md

sudo dd bs=1M if=2017-09-07-raspbian-stretch.img of=/dev/sdh conv=fsync

Configure ssh access

Reference: https://www.raspberrypi.org/documentation/remote-access/ssh/

Install the ob2 server (run on the pi)

See: This bash script

Wait a bit

~20 minutes? for ob2-server to initialize and download btc blockchain and stuff

Monitor progress by watching:

tail -f /ob2/logs/*

CTL+C to stop viewing the logs

ob2 configuration:

Reference: https://freedomnode.com/blog/80/how-to-install-and-configure-new-openbazaar-2-0-on-linux-and-mac-os-x docker kill ob2-server

cd /ob2

sed -i -E "s|(\"Gateway\": \"/ip4/)127.0.0.1|\10.0.0.0|" config

Set user and password

sudo apt install hashalot

USERNAME=foo

PASSWORD=barbaz

PWSHA256=$(echo ${PASSWORD} | sha256 -x)

sudo sed -i "s/\"Username\": \"\"/\"Username\": \"$USERNAME\"/g" config

sudo sed -i "s/\"Password\": \"\"/\"Password\": \"$PWSHA256\"/g" config

Create an ssl certificate

XXX TODO

Restart the server with these settings

docker run --net=host -v /ob2:/var/lib/openbazaar --name=ob2-server ob2-server

Install the ob2 desktop (run on the pi, or your desktop)

See: This bash script cd ~/openbazaar-desktop npm start

Wait a bit for the GUI to come up and render (~5 minutes)

Configure a new server connection with:

  • Name: pi
  • Server IP: localhost
  • Username: foo
  • Password: barbaz
  • SSL: Off
  • Port: 4002
#!/bin/bash
echo "If you are starting ob2-desktop over SSH you need to"
echo "enable ssh X11 forwarding, and xhost"
# Install NodeJS
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install nodejs
sudo apt-get install git
git clone https://github.com/OpenBazaar/openbazaar-desktop.git
cd openbazaar-desktop
npm install
npm start
#!/bin/bash
# Pre-Req:
echo "Install Raspbian image on your rpi"
echo ""
echo "Find the IP address of your rpi:"
echo "ifconfig | grep "inet " | grep -v 127.0.0.1 | awk '{print $2}'"
echo ""
echo "Please run 'sudo raspi-config' and setup:"
echo "1) Change Password"
echo "2) Set a hostname"
echo "3) Interfacing Options -> Enable SSH"
echo "4) Reboot"
echo ""
echo "Verify you can log in via SSH"
echo "ssh pi@<ip-found-above>"
echo ""
echo "The following commands are run on the Raspberry Pi"
# Update:
sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get -y dist-upgrade
sudo init 6
# Add Docker
curl -sSL https://get.docker.com | sh
sudo usermod -aG docker pi
sudo init 6
# Clone the ob2 server git project
sudo apt-get install -y git
git clone https://github.com/OpenBazaar/openbazaar-go.git
cd openbazaar-go
# Create a Makefile for easy commands
cat > Makefile << EOF
build:
docker build -t ob2-server .
run:
-docker kill ob2-server
-docker rm ob2-server
docker run -d --net=host -v /ob2:/var/lib/openbazaar --name=ob2-server ob2-server
stop:
docker stop ob2-server
EOF
sed -i 's/^ /\t/g' Makefile
sed -i 's/^FROM.*$/FROM resin\/raspberry-pi-golang/g' Dockerfile
# Build the ob2-server Docker image
make build
# Start the ob2-server
make run
# See what its doing - Note, it will take a while to initialize
# watch -c "docker logs ob2-server 2>&1 | tail -n 20"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment