Tag Archives: Setup

Install Ouimeaux on Raspberry Pi

I am working on a custom home automation solution that combines several different systems in a single easy to use control panel. The design is to have a Raspberry Pi 3 B running Ubuntu Mate 16.04 LTS become a hub device that can control all the devices that have automation built in.

The first item on my list is to get my WeMo setup responding to basic commands, to do this we will be installing ouimeaux. The first step is to install the the prerequisites.
sudo apt-get install python-setuptools python-dev python-pip

Next we will run the installer, we will install the server version so that we can use the default web interface and use the REST API in a later project.
sudo pip install ouimeaux[server]

We will need to open a port on the firewall or we will not get any response from any device, I am using ufw. We need to port 54321 for discovery of devices, 5000 for the rest api for the server, and 80 if you will be running the web app.
sudo ufw allow 54321
sudo ufw allow 5000

Now we will want to see if everything is working properly by running the following command to detect and list any devices found.
wemo list

If everything worked properly we should see a list of devices returned like the example below.
Bridge: WeMo Link
Light: lightBedroom
Light: lightHallway

If everything is working properly you can now start the server by running wemo server, if you wanted to keep the server running in the background it would be best to launch with the server with screen or a cron job. you can now open your browser to http://localhost:5000/ to use the page control page provided with Ouimeaux.

Install and configure CJDNS on Ubuntu 14.04

I have wanted to create a way to secure the communicates between the my VPS’s that are located at several geologically different datacenters. Normally each server being it’s own island is not an issue, but this does not work very well if you want the servers to communicate on a secure channel for monitoring and deploying configuration. This type of communication is normally done on an internal network that does not route publicly. Some of the more standard configuration options would be to setup a VPN, or host all the systems in one location on the same subnet. These options are all good but do provide the same interest as setting up CJDNS to route the traffic. Here I will cover how to setup CJDNS to communicate between two freshly installed Ubuntu 14.04 systems.

First we need to install the the prerequisites to build the current version of CJDNS.
sudo apt-get install git build-essential nodejs

Next we will need to download a copy of the project from GIT and run the build.
sudo mkdir -p /opt/cjdns
sudo git clone https://github.com/cjdelisle/cjdns.git /opt/cjdns
cd /opt/cjdns
sudo ./do

CJDNS will use the tun device to communicate, we need to verify that it is working properly.
cat /dev/net/tun
If we see cat: /dev/net/tun: File descriptor in bad state then everything is working properly at this stage.
If we see cat: /dev/net/tun: No such file or directory we will need to create the tun device by running the following commands.
sudo mkdir -p /dev/net
sudo mknod /dev/net/tun c 10 200
sudo chmod 0666 /dev/net/tun
cat /dev/net/tun

If we get the result of cat: /dev/net/tun: Operation not permitted it is likely that your VPS provider has not enabled TUN/TAP device by default. You will need to be activated the TUN/TAP device from the VPS control panel, or by creating a support ticket with your VPS provider.

Next we need to generate the the config file.
sudo mkdir -p /etc/cjdns
sudo chmod 755 /etc/cjdns
./cjdroute --genconf > ~/cjdroute.conf
sudo mv ~/cjdroute.conf /etc/cjdns/cjdroute.conf

Now we need to make some changes to the config file. Open ‘/etc/cjdns/cjdroute.conf’ in an editor and make the following changes.
Find the setting "beacon": 2; and change it to "beacon": 0; to prevent connections to other systems that are broadcasting.
Find the line "your.external.ip.goes.here" in the "authorizedPasswords" section and replace it with your external IP address. In the same section locate the line "peerName":"your-name-goes-here" And change the value "your-name-goes-here" to a human readable name for the system like "CortanaRouter1".

Next copy the connection credentials that we just configured, they should look like this:
"": {
"login": "default-login",

This is an example connection and will not work if used. We will now past this into the "connectTo" section for IPv4 or IPv6 depending on what the system.

We will want to set one of the systems to print the log to the terminal for testing by changing the following settings. First we will set "noBackground":0, to "noBackground":1, and uncommenting the line "logTo":"stdout" in the config. Remember this step is for testing only will will need to be reverted after we have confirmed that the setup is functional.

Now we will want to start the service on the systems by running the following command.
sudo /opt/cjdns/cjdroute < /etc/cjdns/cjdroute.conf

To test if the connection has been setup successfully we will want to ping the IPv6 address assigned to the tun device. The IPv6 address is located at the start of the config file at the setting "ipv6": "fc1b:ddbd:29f1:39fe:95e8:122:4c30:f253",.

Now that we have a CJDNS working we need to setup a proper init script to run on startup, and to control the service. I have modified the init script provided at https://github.com/ProjectMeshnet/CJDNS-init.d-Script/ to work with this guide, you can download it from https://www.jenovarain.com/blog/wp-content/uploads/2016/05/cjdns.txt.

Run the following commands to download and configure the script.
wget https://www.jenovarain.com/blog/wp-content/uploads/2016/05/cjdns.txt
sudo cp cjdns.txt /etc/init.d/cjdns
sudo chmod +x /etc/init.d/cjdns
sudo update-rc.d cjdns defaults

You can now test the new init script by running the following command:
sudo service cjdns status
You should see Cjdns is running if everything is working properly.

You should now have CJDNS setup and configured to start on boot and peered with both system letting you securely route data between the two systems.

We have not covered restricting communication between the systems to only use this new route, and how to segregate peer connections if you connect to other CJDNS peers.

Ghostscript Setup Windows 8 64 bit

If you are supporting custom software or older line of business software that your organization needs to operate you might come across an issue with Ghostscript and windows 8 64 bit.

The issue is simply when you try to add the Ghostscript printer windows 8 will look like it is stuck in a loop, if you check the error logs you will find an error that look like this.
Log Name: Application
Source: Windows Error Reporting
Event ID: 1001
Level: Information
Fault bucket -1485095716, type 5
Event Name: PnPDriverImportError
Response: Not available
Cab Id: 0

Problem signature:
P1: x64
P2: E000022F
P3: ghostpdf.inf
P4: 9fa1429c89509ac5eb7661ffa0fa86850304a1fd
To install the Ghostscript printer follow these steps:

  1. Open your charms (the right side popup menu) and select “Settings” and Click on the last option on the list called “Change PC Settings”
  2. In the “General” category click the “Restart now” button under “Advanced startup”
  3. Then the system restarts it will show you several options, you want to select “Troubleshoot” then “Advanced options” and finally “Startup Settings”
  4. The system will reboot one more time and you will have a new listing of options, you will want to select option #7 “Disable Driver Signature Enforcement”
  5. After the system has finished restarting for the final time you will be able to add the Ghostscript printer to windows 8 64 bit.

The final item of note is that you must select “File: (print to file)” as the port for the printer as “LPT1” will not work.

You can download the latest version of Ghost script from this website http://www.ghostscript.com/.

Setup Windows To Go on a USB Drive

The idea of a windows to go setup for Windows 8 is very interesting and I have wanted to try this as soon as I hear about it. After doing some research and testing I have managed to get a working copy of Windows To Go to work on a 32GB USB drive.

Now I have seen that this is not the fastest thing in the world, but this is because of some simple reasons. The drive I am using is only USB 2.0 not USB 3.0 making it rather slow, as well as the drive is just not that great to start with. I still really like to use the device and it is a lot of fun to use when you’re at someones house and you want to browse or do work but you do not want to use their computer.

You will need the following.

How to setup the drive.

  • From a command prompt
  • Run: diskpart
  • At the DISKPART> prompt find your USB drive by typing: list disk
  • Select your USB drive by typing: select disk 2 (if your drive is listed as drive 2)
  • Prep the drive by typing: clean
  • Now we create a partition: create partition primary
  • The partition needs to be formatted and set as bootable: format fs=ntfs quick
  • Set the drive letter for the partition: assign letter=W
  • Set the partition as active: active
  • Exit diskpart: exit

You will now need to get a file off the Windows 8 DVD ISO and a copy of imagex.exe. To access the files in the ISO I recommend using winrar as it can open ISO files. The file you need is called install.wim and it is located in the sources folder in the ISO, copy this file to your local hard drive I recommend the C:\temp\ as it is simple to access from the command prompt.

Windows 8 ISO, install.wim location

Windows 8 ISO, install.wim location

You will also need to get a copy of imagex.exe. This is not a simple file to find, you can use Windows AIK but I do not like to download such a large file for a tiny program. I found this great tool called Waik Tools, this will download only the parts that you need. After you have imagex.exe copy it to the same location as your install.wim file.

We can now install Windows on to the drive, to do this run the following command. (change drive letters and paths to what you have set your self)
imagex.exe /apply c:\temp\install.wim 1 W:

After this has run you need to create to boot records on the drive, run the following command.
bcdboot.exe W:\windows /s W: /f ALL

The drive will work properly at this point but it still needs two more changes to make it shine. You will need to apply a SAN policy to take the internal drives offline preventing any changes to the internal drives. This is done by creating a file called san_policy.xml and placing it in the root of the drive with the following contents.

<?xml version='1.0' encoding='utf-8' standalone='yes'?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
 <settings pass="offlineServicing">

After you have placed this file in the root of the drive run this command: (this command only works on Windows 8)
dism.exe /Image:W:\ /Apply-Unattend:W:\san_policy.xml

You will now want to create an answers file that will disable the Windows Recover Enviroment for the drive. Create a file called unattended.xml with the following contents.

<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
 <settings pass="oobeSystem">
 <component name="Microsoft-Windows-WinRE-RecoveryAgent"
 publicKeyToken="31bf3856ad364e35" language="neutral"
 <component name="Microsoft-Windows-WinRE-RecoveryAgent"
 publicKeyToken="31bf3856ad364e35" language="neutral"

Save this file as unattended.xml to the sysprep folder on the drive. (W:\Windows\System32\sysprep\)

You should now be ready to use your drive. all you need to do now is boot from it. The first time you boot to the drive on a new computer it will take some time to setup but after that it will be a lot faster to boot.