Author Archives: christroutner

About christroutner

Check out my blog at http://sanjuansufficiency.com and http://thesolarpowerexpert.com

Setting Up KeystoneJS CMS in Ubuntu

I wanted to play around with the KeystoneJS CMS. This is a simple, bare-bones CMS that is natively written in JavaScript. It took quite a bit of work to get it up and running, so this page documents the steps involved to get a real, live running version.

I could have developed this on the Raspberry Pi, but instead opted to use a virtual server hosted by Digital Ocean. They only cost $5 per month and the ability to save and restore snapshots is even faster than re-flashing the SD card on the R-Pi. Either way, all the setup and configuration was done on the command line using SSH.

So without further ado, here are the steps I needed to take to get KeystoneJS up and running on a Ubuntu 14.04 Droplet:

  1. Log in as root
  2. Setup Mongo DB by executing the following code: (adapted from this Digital Ocean tutorial)

    • apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
    • echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list
    • apt-get update && apt-get -y upgrade
    • sudo apt-get install -y mongodb-org
  3. Install the following support packages:

    • apt-get install make
    • apt-get install git
    • apt-get install g++
  4. Add a local user. In this case I’m calling him ‘trout’:

    • adduser trout
    • adduser trout sudo
  5. This is a great time to shutdown the VM and take a snapshot. (optional)
  6. Log in as your new user.
  7. Install NVM (to run older versions of Node and NPM).

    • curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.29.0/install.sh | bash
  8. Log out and log back in as your regular user (‘trout’).
  9. Install Node 0.10.36:

    • Note: This will give you warnings that node and npm are outdated. Ignore these warnings. 0.10.13 is too old to work and 0.12.7 (latest as of this writing) will break KeystoneJS because it is too new. There may be other versions that work, but these are what I’ve tested.
    • nvm install 0.10.36
  10. Install the Yeoman Keystone Generator:

    • npm install -g generator-keystone
  11. Run the Yeoman Keystone Generator:

    • yo keystone
    • Follow the on-screen prompts. Just hit if you want to accept all quickly accept all defaults and test if you can even get KeystoneJS running.
  12. Change directory and run KeystoneJS:

    • By default KeystoneJS will install into a directory called ‘my-site’.
    • cd my-site
    • node keystone
  13. Access your new website view port 3000. If you’re using a Digital Ocean Droplet like me, you can simply type in the IP address is your web browser like this: http://555.555.555.555:3000. If you’re using a Raspberry Pi, use the IP address of your Pi.

These are the steps that I was able to take and get KeystoneJS up and running. I hope it helps other people from having to spend two days figuring them out, like it took me.

New Freedombox Raspberry Pi Image

James Valleroy wrote the group to announce he had a new Raspberry Pi image. I haven’t tested it, but I thought I’d post it here to make it easier for others to find. Please post in the comments if you are able to successfully load it onto your Raspberry Pi.


Date: Fri, 15 Aug 2014 07:56:02 -0400
To: FreedomBox discussions

Subject: Re: [Freedombox-discuss] Image for Raspberry Pi

I have uploaded a new raspberrypi image here:
http://compcube.info/~jvalleroy/wiki/

Current known issues:
– Doesn’t include XMPP server or client.
– Plinth templates are broken.

I’ll try to upload new images for each platform on a regular basis.

Purchasing an MPG2 License

One of the notes that I saw was that XBMC takes control of the video output directly and does not use the XOrg GUI. If Raspbian is set to boot to desktop, it is advantageous to reconfigure it to boot to command prompt so that resources aren’t wasted. This can be done with the following command:


sudo raspi-config

Follow the prompt to reset the Pi boot settings.

I also switched from a VGA monitor to a TV with an HDMI input port. I didn’t want any VGA configuration settings to get in the way of running XBMC. I will play with these alternative setting later, once I confirm that the native HDMI output works properly. That means I had to comment out the line in the /boot/config.txt file that were setting my Pi to VGA mode (see earlier posts).


Launching XBMC

I’m more in the habit of controlling the Pi over SSH from my laptop, rather than with a keyboard and mouse plugged into it, so keep that mind. At the very least, it explains my preference for command line control.

Once I rebooted the Pi, I logged in over SSH as user pi. I was able to launch XBMC with this command:


xbmc-standalone &

The ampersand just tells the OS to run the program in the background. Otherwise it will block your command line interface and you’ll have to open another one. I was excited to see that XBMC took control of the HDMI output and ran flawlessly.

XMBC on Raspberry Pi

XMBC running on the Raspberry Pi


Mounting a Flash Drive

After confirming that XBMC would run properly, the next step was to see if it would play a DVD ISO file. These are DVDs from my library that I have backed up with Any DVD and Power ISO.

I shut down XBMC and loaded an ISO file onto a USB flash drive, which I plugged into the Raspberry Pi USB port. I rebooted the Pi just to be safe. After a few tries, I was able to mount the USB flash drive with these commands:


sudo mkdir /mnt/usb
sudo mount /dev/sda1 /mnt/usb

I then launched XBMC and it was able to read the ISO file!


Need an MPG2 License

After loading the ISO file into XBMC and hitting play, a small stream of music came out, but no video. Hmm…

After a little bit of digging, I found this XBMC forum thread. It turns out that some part of the DVD ISO file uses the MPG2 encoding format, and I need to buy a license to enable the Raspberry Pi’s FPGA to run it. The thread lead me to the Raspberry Pi Store, where I was able to buy a license for $3.48.

Unfortunately, the license file isn’t an instant download, so I had to wait until I got the license this morning. I have received it, and I’ve also followed the instructions to load it into the /boot/config.txt file. I should be able to play back the DVD ISO file this afternoon!

I’ll report back with results.

In the meantime, a member of the FreedomBox mailing list posted a link to this inspiring YouTube video:

Creating a Media Server

Since I started playing with my Raspberry Pi/FreedomBox, I’ve been talking about it with my friends and family (all non-geeks). They all think the software the Freedombox provides is cool, but not enough for them to shell out $100 for it. However, I’ve also been telling them about how the Raspberry Pi can be converted into a media server, and they have all shown incredible excitement over that.

Let me back up and explain exactly what a media server is, for the sake of this discussion:


What is a Media Server?

In terms of functionality, a media server is a device that contains and serves media, like music and movies. Think of a DVD player that can save your movies and music and play them back for you on-demand.

In terms of hardware, a media server is simply a Raspberry Pi connected to a TV, and most likely, a portable hard drive plugged into one of its USB ports. Your MP3 music files and DVD ISO (like those made with AnyDVD) can be uploaded to the hard drive and the Raspberry Pi can read them, and play them back on the TV. This same hardware setup (minus the TV connection), by the way, is identical to the minimum requirements to run OwnCloud, a personal cloud server. OwnCloud is one of the packages that is targeted for implementation in the FreedomBox project.


Combining a FreedomBox and Media Server

Why not have both a Media Server and a FreedomBox combined? This is the idea that I pitched to the FreedomBox group and got a variety of replies.

One important objection is that the Raspberry Pi probably does not have the bandwidth to do both. As an embedded computer, running a media server is probably going to push it to the limits of it’s computational power. There are several demonstrations that the Raspberry Pi is quite able to perform as a media center. However, FreedomBox services will probably have to be shut down or throttled during DVD playback. Alternatively, two Raspberry Pi’s could be connected together – one running the media server, the other running the FreedomBox software.


Experimenting with a Media Server

All this research convinced me to spend some time playing around with software and see how hard it would be to get a media server going. I made a backup image of the working Freedombox I had loaded on the Pi and reinstalled NOOBS with Raspbian (see previous posts on how to do all this).

While there is a variety of software that can be used as a media server, the most popular by far is XBMC. XBMC can not be installed with apt-get on the Pi as it is reported as a broken package in Raspbian. However, installation is not much more difficult than that. I found these two helpful pages:

Using my SSH remote-admin console, I was able to follow the binary install guide to the point that I should now be able to plug the Pi into a TV and run XBMC. I’ll give it a go this afternoon and report back with my findings.

I also need to verify that the Pi will detect and read my portable hard drive.

Broken Build?

I’ve been working with the Freedombox mailing list over the last week to figure out why I’m having such a hard time getting a working build. The odd thing is that I can build the image, but the Raspberry Pi will not boot. They’ve been incredibly helpful and the evidence is mounting that the build is actually broken. Here is the latest email with the evidence. Check the mailing list archives for April and May to get all the gory details.

The good news is that you anyone can still build a working Freedombox with a Raspberry Pi by using Pere’s image from 3-20, which can be found on this ftp server and follow the steps I documented here on the blog.

Resizing the File System

After reaching out to the mailing list, it was suggested that I use gparted, the graphical implementation of parted, to resize the partition. It was also pointed out that I went rogue in my implementation of PageKite, which probably explains my unsatisfactory results.

I decided to reflash the SD card with Pere’s Freedombox image. After doing that, I used gparted to resize the root partition to take up the rest of the space on the SD card. gparted was refreshingly intuitive to use.

gparted - graphical parted, used to resize the file system to take up the entire SD card.

gparted – graphical parted, used to resize the file system to take up the entire SD card.

I’m also going to play around a bit more with the Plinth implemented version of PageKite on the Freedombox. I’ll report back with the results.

Setting Up Reverse DNS

I finally got my Freedombox connected to the internet. Several emails in the Freedombox mailing list indicated that I needed to extend the file system after booting, but no one said exactly how. I found this great article on how to use parted to resize the partition, but I figured the chance of me screwing it up was pretty high. I’ll wait a day and see what the mailing list says.

Despite that roadblock, I still had enough free space on the default 3GB partition to run the following commands:


sudo apt-get update
sudo apt-get curl

curl -s https://pagekite.net/pk/ |sudo bash

pagekite.py 80 yourname.pagekite.me

Once I got through the login screen of pagekite, the program was now blocking. However, I was able to shut it down with CNTRL-C and then restart it in the background with:


pagekite.py &

However, it was still periodically reporting, which was kind of annoying. Another thing I need to reach out to the mailing list about.


Installing DynDNS

After getting Pagekite installed, I realized that it only allowed an HTTP (Port 80) connection. I couldn’t figure out how to setup Pagekite to allow SSH through. However, the router my Freedombox was connected to was configured to use DynDNS.org. I’ve used DynDNS to setup reverse DNS for both HTTP and SSH. I will need SSH to do remote administration on the Freedombox, so that’s pretty important to me.

DynDNS is $25 per year, so it’s not free, but they’ve been around a *long* time and most routers are configured to use it. For me, it’s the path of least resistance.

After creating an account on DynDNS (they have a 14 day free trial, by the way), I was able to forward port 80 and 22 to the Freedombox. Now I can access the web server and the SSH server on the Freedombox remotely!

Successfully Loading Freedombox

Despite ‘successfully’ building a freedombox image in Debian Jessie, the Raspberry Pi didn’t do anything after I loaded the image onto the SD card with Win32 Disk Imager. I will eventually figure out why, but I’ll save that adventure for a later date. I reached out to the #freedombox IRC channel and learned that Pere regularly publishes Freedombox builds on his ftp site. I was able to grab the v0.2 Raspberry Pi image from there. (Note: The image I test below was built 3/20/14).

Using the Win32 Disk Imager, I was able to load Pere’s image onto the SD card and successfully boot it.

IMG_20140422_110943

As far as I know (as of this writing), Freedombox is not designed to run with a display like NOOBS or Raspbian is. At least, there is no /boot/config.txt file for me to edit like there was in Raspbian. However, I was able to SSH into the device with the login/pass: root/freedom and interact with the Freedombox this way.

I am now using my netbook to talk to the Raspberry Pi Freedombox over ethernet. I am using DHCP server to handle the ethernet communication and PuTTY for the SSH communication. I am now diving into the Freedombox Documentation to get my box setup and customized!


To-Do:

  • Setup Pagekite or some other reverse proxy service
  • Figure out how to extend the file system to take up the rest of the SD card
  • Figure out a good file sharing and cloud backup software to run

Getting VGA to Work

Playing around with Raspbian wasn’t as strait-forward as I had hoped. As soon as I got Raspian loaded onto the SD card, the VGA monitor stopped working again. Below are the steps I took to get it working again.

With Raspbian loaded, I can now SSH into the device even though there is no screen display. I connected it to the ethernet input of a router and connected my laptop to another port on the same router. Looking at the IP tables, I saw that the raspberry pi was assigned an IP address of 192.168.101.

default ssh login for raspbian:
pi/raspberry

initiate ssh with this command:

ssh pi@192.168.1.101

That IP address was the one assigned to the raspberry pi by my router.

for root/su operations, use the sudo command. SU will request a password, which is *not* ‘raspberry’. But sudo does not require a password.


VGA vs HDMI

It took me a bit of research to figure this out. In order to get the VGA monitor working, I had to change the /boot/config.txt file to startup in HDMI safe mode. After I did not, the screen flickered, but I didn’t get any picture.

Was able to edit the file with this command:

sudo nano /boot/config.txt

Enabled HDMI-safe mode, but still didn’t get any picture.

Enabled hdmi_force_hotplug, hdmi_group, and hdmi_mode… still no picture.

Disabled (commented out) HDMI safe mode, and I got a video output on my VGA monitor!!!

So, the moral is that you have to comment:
htmi_safe

uncomment:
htmi_force_hotplug
hdmi_group
hdmi_mode

The official reference page for the config.txt file:
http://elinux.org/RPiconfig