{"id":8460,"date":"2018-11-24T10:29:40","date_gmt":"2018-11-24T10:29:40","guid":{"rendered":"http:\/\/johnjohnston.info\/blog\/?p=8460"},"modified":"2021-09-20T22:25:07","modified_gmt":"2021-09-20T21:25:07","slug":"nodestorage-on-a-headless-raspberry-pi","status":"publish","type":"post","link":"https:\/\/johnjohnston.info\/blog\/nodestorage-on-a-headless-raspberry-pi\/","title":{"rendered":"Nodestorage on a Headless  Raspberry Pi"},"content":{"rendered":"<p>These are some notes on getting some of Dave Winer&#8217;s web tools that use <strong>node<\/strong> running on a Raspberry pi.<\/p>\n<p>I&#8217;d originally posted these on the pi, but the SD card was corrupted and I&#8217;d no back up (I&#8217;ve had that lesson a few times).<\/p>\n<p>These note are not likely to be of interest to many and are somewhat abrupt.<\/p>\n<p><!--more--><\/p>\n<p>There are probably many ways to do this but this fits my situation. I have a computer, I don&#8217;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.<\/p>\n<p>So I play on the pi via the command line and secure shell from the terminal app on my mac.<\/p>\n<h3>Prerequisites<\/h3>\n<p>You need to be a wee bit familiar with the command line. There are many guides to that <a href=\"https:\/\/lifehacker.com\/5633909\/who-needs-a-mouse-learn-to-use-the-command-line-for-almost-anything\">here is one<\/a><\/p>\n<p>I run these on a Model B Rev 2 512MB pi. But to write these notes I&#8217;ve redone some of the setup on a Pi Zero v1.3 which also has 512MB ram.<\/p>\n<p>I also needed a Wifi dongle, and MicroUSB &gt; USB adapter to fit it and a power supply. The Zero W would be a better cheapest choice.<\/p>\n<p>You need a computer, I use a mac and the terminal app, you can, I believe, use <a href=\"https:\/\/en.wikipedia.org\/wiki\/PuTTY\">PuTTY &#8211; Wikipedia<\/a> on windows. Linux, of course comes with a terminal too. I&#8217;ve never changed from the BASH shell that is the default on my mac.<\/p>\n<h3>Basic set up and connection<\/h3>\n<p>I followed these guides from for the initial setup.<\/p>\n<ul>\n<li><a href=\"https:\/\/learn.adafruit.com\/raspberry-pi-zero-creation\/overview\">Overview | Raspberry Pi Zero Headless Quick Start | Adafruit Learning System<\/a><\/li>\n<li><a href=\"https:\/\/www.losant.com\/blog\/getting-started-with-the-raspberry-pi-zero-w-without-a-monitor\">Getting Started with the Raspberry Pi Zero W without a Monitor | Losant Enterprise IoT Platform<\/a><\/li>\n<\/ul>\n<p>Download <a href=\"https:\/\/www.raspberrypi.org\/downloads\/raspbian\/\">Latest Jessie Lite<\/a><\/p>\n<p>Download <a href=\"https:\/\/etcher.io\">etcher<\/a> to burn the OS to your SD card.<\/p>\n<p>Then follow this to set up your SD card: <a href=\"https:\/\/www.raspberrypi.org\/documentation\/installation\/installing-images\/README.md\">Installing operating system images &#8211; Raspberry Pi Documentation<\/a><\/p>\n<p>Once burned os you need to create 3 files on the disk, the disk is now named boot.<\/p>\n<p>Eject and re insert disk so it mounts<\/p>\n<p>Edit 3 files: wpa_supplicant.conf, config.txt and SSH<\/p>\n<p>*wpa_supplicant.conf *<\/p>\n<p><strong>Create<\/strong> this and edit:<\/p>\n<p>network={<br \/>\nssid=&#8221;YOURSSID&#8221;<br \/>\npsk=&#8221;YOURPASSWORD&#8221;<br \/>\nscan_ssid=1<br \/>\n}<\/p>\n<p><em>config.txt<\/em> this file <strong>already exists<\/strong><\/p>\n<p>add this to bottom:<\/p>\n<h1>Enable UART<\/h1>\n<p>enable_uart=1<\/p>\n<p>create a file <em>SSH<\/em> with no file extension, it needs no content<br \/>\nThis will allow you to connect to the Pi vis ssh which is disable by default.<\/p>\n<p>Eject the disk, put it in the pi and connect the pi to power. (assuming the wifi dongle is attached).<\/p>\n<p>Wait a minute or two. lights will flash.<\/p>\n<p>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&#8217;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.<\/p>\n<p>So I can open the terminal and type:<\/p>\n<p><code>ssh pi@theIPADDRESS<\/code><\/p>\n<p>but<\/p>\n<p><code>ssh pi@raspberrypi<\/code><\/p>\n<p>also works ( I wonder if there is a clash if more than one pi on the network where the name has not been changed)<\/p>\n<p>on typing the above command I get a message about<\/p>\n<p>`The authenticity of host &#8216;raspberrypi (IPADDRESS)&#8217; can&#8217;t be established. and more and asking if I want to continue. I type yes and press return.<\/p>\n<p>I am then challenged for the password which is raspberry (I change that ASAP).<\/p>\n<p>I am then logged onto the pi and subsequent commands will be run there.<\/p>\n<p>House Keeping<\/p>\n<p>sudo apt-get update<\/p>\n<p>sudo apt-get upgrade<\/p>\n<p>sudo-raspi-config<\/p>\n<p>Change the password, expand the os, give the pi a name (or change it if you want)<\/p>\n<h3>Install node<\/h3>\n<p>wget http:\/\/node-arm.herokuapp.com\/node_latest_armhf.deb<\/p>\n<p>then install:<\/p>\n<p>sudo dpkg -i node_latest_armhf.deb<\/p>\n<h3>River5<\/h3>\n<p>Download river5<\/p>\n<p>wget https:\/\/github.com\/scripting\/river5\/archive\/master.zip<\/p>\n<p>and unzip<\/p>\n<p>unzip master.zip<\/p>\n<p>running ls will show a folder river5-master which has all the river5 files in in<\/p>\n<p>move into that folder<\/p>\n<p>cd river5-master<\/p>\n<p>and<\/p>\n<p>npm install<\/p>\n<p>then<\/p>\n<p>node river5.js<\/p>\n<p>A huge about of stuff will scroll up in the terminal<\/p>\n<p>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<\/p>\n<p>You can also, at least in my home setup use http:\/\/raspberrypi-zero-node.local:1337 where <em>raspberrypi-zero-node<\/em> is the name of my raspberry pi, set in the config above.<\/p>\n<p>to stop the server just type control-c the scrolling of text will stop and you will be returned to the command prompt.<\/p>\n<h4>forever<\/h4>\n<p>Running River5 this way will not keep it running if it hits problems. Dave suggests using <a href=\"https:\/\/github.com\/foreverjs\/forever\">forever<\/a> to keep it going.<\/p>\n<p>This turns out to be pretty easy:<\/p>\n<p>his is pretty simple you install Forever with:<\/p>\n<p>sudo npm install forever -g<\/p>\n<p>npm is a package manager for node so it installs stuff.<\/p>\n<p>After it is installed we can start up the river5 with:<\/p>\n<p>forever start river5.js<\/p>\n<p>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.<\/p>\n<h3>More<\/h3>\n<p>I&#8217;ve not covered so far:<\/p>\n<ul>\n<li>making the pi available on the internet<\/li>\n<li>security for the above<\/li>\n<li>adding 1999, MyWord and Little Outliner to the mix, I <del>have all<\/del> had these hooked up to my pi at <a href=\"http:\/\/pi.johnj.info\" title=\"john's pi server\">john&#8217;s pi server<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>These are some notes on getting some of Dave Winer&#8217;s web tools that use node running on a Raspberry pi. I&#8217;d originally posted these on the pi, but the SD card was corrupted and I&#8217;d no back up (I&#8217;ve had that lesson a few times). These note are not likely to be of interest to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"mf2_syndication":[],"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"webmentions_disabled_pings":false,"webmentions_disabled":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[861],"tags":[443,543,545,727],"post_format":[],"class_list":{"0":"post-8460","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-article","7":"tag-bash","8":"tag-dave-winer","9":"tag-node","10":"tag-raspberry-pi","11":"kind-article","13":"h-entry","14":"hentry"},"better_featured_image":null,"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p57zFQ-2cs","jetpack_likes_enabled":false,"jetpack_sharing_enabled":true,"kind":false,"_links":{"self":[{"href":"https:\/\/johnjohnston.info\/blog\/wp-json\/wp\/v2\/posts\/8460","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/johnjohnston.info\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/johnjohnston.info\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/johnjohnston.info\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/johnjohnston.info\/blog\/wp-json\/wp\/v2\/comments?post=8460"}],"version-history":[{"count":2,"href":"https:\/\/johnjohnston.info\/blog\/wp-json\/wp\/v2\/posts\/8460\/revisions"}],"predecessor-version":[{"id":8462,"href":"https:\/\/johnjohnston.info\/blog\/wp-json\/wp\/v2\/posts\/8460\/revisions\/8462"}],"wp:attachment":[{"href":"https:\/\/johnjohnston.info\/blog\/wp-json\/wp\/v2\/media?parent=8460"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/johnjohnston.info\/blog\/wp-json\/wp\/v2\/categories?post=8460"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/johnjohnston.info\/blog\/wp-json\/wp\/v2\/tags?post=8460"},{"taxonomy":"post_format","embeddable":true,"href":"https:\/\/johnjohnston.info\/blog\/wp-json\/wp\/v2\/post_format?post=8460"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}