Nodestorage on a Headless Raspberry Pi

These are some notes on getting some of Dave Winer’s web tools that use node running on a Raspberry pi.

I’d originally posted these on the pi, but the SD card was corrupted and I’d no back up (I’ve had that lesson a few times).

These note are not likely to be of interest to many and are somewhat abrupt.

There are probably many ways to do this but this fits my situation. I have a computer, I don’t have a spare monitor to use with the PI and it is too much hassle to plug int into the tv and a keyboard every time I want to change something on a PI.

So I play on the pi via the command line and secure shell from the terminal app on my mac.

Prerequisites

You need to be a wee bit familiar with the command line. There are many guides to that here is one

I run these on a Model B Rev 2 512MB pi. But to write these notes I’ve redone some of the setup on a Pi Zero v1.3 which also has 512MB ram.

I also needed a Wifi dongle, and MicroUSB > USB adapter to fit it and a power supply. The Zero W would be a better cheapest choice.

You need a computer, I use a mac and the terminal app, you can, I believe, use PuTTY – Wikipedia on windows. Linux, of course comes with a terminal too. I’ve never changed from the BASH shell that is the default on my mac.

Basic set up and connection

I followed these guides from for the initial setup.

Overview | Raspberry Pi Zero Headless Quick Start | Adafruit Learning System

Getting Started with the Raspberry Pi Zero W without a Monitor | Losant Enterprise IoT Platform

Download Latest Jessie Lite

Download etcher to burn the OS to your SD card.

Then follow this to set up your SD card: Installing operating system images – Raspberry Pi Documentation

Once burned os you need to create 3 files on the disk, the disk is now named boot.

Eject and re insert disk so it mounts

Edit 3 files: wpa_supplicant.conf, config.txt and SSH

*wpa_supplicant.conf *

Create this and edit:

network={
ssid=”YOURSSID”
psk=”YOURPASSWORD”
scan_ssid=1
}

config.txt this file already exists

add this to bottom:

Enable UART

enable_uart=1

create a file SSH with no file extension, it needs no content
This will allow you to connect to the Pi vis ssh which is disable by default.

Eject the disk, put it in the pi and connect the pi to power. (assuming the wifi dongle is attached).

Wait a minute or two. lights will flash.

You need to find the ip address of the pi so that you can connect to it with SSH. There are suggestions that arp -a in the terminal will do this, but that didn’t work for me. I found out the information on the webpage for my home router. This lists all the devices connected and their IP addresses.

So I can open the terminal and type:

ssh pi@theIPADDRESS

but

ssh pi@raspberrypi

also works ( I wonder if there is a clash if more than one pi on the network where the name has not been changed)

on typing the above command I get a message about

`The authenticity of host ‘raspberrypi (IPADDRESS)’ can’t be established. and more and asking if I want to continue. I type yes and press return.

I am then challenged for the password which is raspberry (I change that ASAP).

I am then logged onto the pi and subsequent commands will be run there.

House Keeping

sudo apt-get update

sudo apt-get upgrade

sudo-raspi-config

Change the password, expand the os, give the pi a name (or change it if you want)

Install node

wget http://node-arm.herokuapp.com/node_latest_armhf.deb

then install:

sudo dpkg -i node_latest_armhf.deb

River5

Download river5

wget https://github.com/scripting/river5/archive/master.zip

and unzip

unzip master.zip

running ls will show a folder river5-master which has all the river5 files in in

move into that folder

cd river5-master

and

npm install

then

node river5.js

A huge about of stuff will scroll up in the terminal

Switch to your web browser and put in the following address: theIPaddressOfThePi:1337 eg: http://192.168.1.104:1337 as my pi has an ipaddress of 192.168.104 at the moment

You can also, at least in my home setup use http://raspberrypi-zero-node.local:1337 where raspberrypi-zero-node is the name of my raspberry pi, set in the config above.

to stop the server just type control-c the scrolling of text will stop and you will be returned to the command prompt.

forever

Running River5 this way will not keep it running if it hits problems. Dave suggests using forever to keep it going.

This turns out to be pretty easy:

his is pretty simple you install Forever with:

sudo npm install forever -g

npm is a package manager for node so it installs stuff.

After it is installed we can start up the river5 with:

forever start river5.js

and it keeps going. You need to run this again every time the pi restarts. I believe that you can have this run on startup if you like.

More

I’ve not covered so far:

making the pi available on the internet

security for the above

adding 1999, MyWord and Little Outliner to the mix, I have all had these hooked up to my pi at john’s pi server