Primitive Blog

WEMO: Remote control like X10 but better!

Years ago I set up X10 in the house. It mainly the controlled lights and worked okay. There were problems though. Firstly I had to use a serial based controller that I plugged into one machine so relied on that machine working. Secondly x10 runs over the electric cabling - mostly that was fine but it doesn't traverse circuit rings and sometimes would get interference from other devices. Finally there was no feedback as to whether a command had worked or not, nor any status command.

Wemo fixes all this and more. For about £20 a device you can pick up a little box you plug into an outlet (no wiring needed) and after running an android/iphone app connect it to a local Wifi network. You can now run the the same app on your tablet / phone to turn on and off devices remotely. Now obviously this only works when you are connected to the local wifi so not terribly useful yet.

Next however fire up a little Linux VM (only needs command line access not GUI) and install - Ouimeaux. http://ouimeaux.readthedocs.org/en/latest/readme.html Now you can switch on/off devices remotely, get statuses from a SSH session. Add the commands to the cron and you've got a nice scheduler. What's more there program runs in server mode giving you a simple Web front end. There are other wemo devices too but I've only tried the basic switch model. I may see what the other ones are like too. To my mind this would give you a cheap (£20 after all) remote on/off switch for a server too! It's not quite ipmi but better than nothing.

By Primitive Designs

Dealing with "Shellshock" - patching bash

As everyone hopefully is aware there's a big vunerability with bash. Although that will effect a number of different UNIX derived Openrating Systems, the main target is going to be all those Linux servers out there - even those old ones that you've not touched for years.

For modern systems - Ubuntu 10.04 onwards, Debian 7, Centos 6 etc. then it's either a case of the following two commands

apt-get update ; apt-get install bash

yum install bash

However for anything older than that you need to do it manually. This isn't so hard as you might think. Depending on your machine you may need to install either bash 4.2 or bash 4.3. I certainly had problems installing bash 4.3 on an old Gentoo VM but found 4.2 installed fine. Here's how I did it. The patching part is current but I may have to update it as bash is repatched! First of all ensure you are logged in as root (either using su - or sudo -s). Also ensure youi have the tools for building source code. You need gcc, patch and make at the very least. Then for 4.3 you run

cd /root/
mkdir src
cd src
wget http://ftp.gnu.org/gnu/bash/bash-4.3.tar.gz
for i in $(seq -f "%03g" 0 27); do wget     http://ftp.gnu.org/gnu/bash/bash-4.3-patches/bash43-$i; done
tar zxvf bash-4.3.tar.gz
cd bash-4.3
for i in $(seq -f "%03g" 0 27);do patch -p0 < ../bash43-$i; done
cp /bin/bash /bin/oldbash
./configure --bindir=/bin/ && make && make install

If bash 4.3 won't compile you can try bash 4.2 -

cd /root/
mkdir src
cd src
wget https://ftp.gnu.org/gnu/bash/bash-4.2.tar.gz
for i in $(seq -f "%03g" 0 50); do wget     http://ftp.gnu.org/gnu/bash/bash-4.2-patches/bash42-$i; done
tar -zxvf bash-4.2.tar.gz
cd bash-4.2
for i in $(seq -f "%03g" 0 50);do patch -p0 < ../bash42-$i; done
cp /bin/bash /bin/oldbash
./configure --bindir=/bin/ && make && make install

to ensure the install went through just run bash -version and make sure it comes up with either bash 4.2 or bash 4.3. You can test that it deals with the current bash exploits by running

env var='() {(a)=>\' bash -c "echo date"; cat echo

If youy see the date displayed at the bottom of the output you've still got a problem. Double check what you did. If not then you're safe for now...

By Primitive Designs

Taking a screenshot for fun or profit...

A lot of people will know this one now but a few of you might not. It's a basic tool most techies use to capture an image of exactly what is happening on the screen. Why would you want to use it? Maybe you tried to buy something online and it's thrown up an error message. Maybe you've got a weird error screen from a program you use. Maybe you simply want to keep an image of your desktop for posterity - "Look I really did do that online game in 30 seconds!". The Print screen option has been available since the dark ages of IT back when it would simply output whatever was displayed to your dot matrix printer! Nowadays it simply allows you to create an image.
 
How do you do it? Easy. In all versions of Windows simply hit the "Print Screen" button. it should be a little key on your keyboard over to the top right next. Once you hit it nothing will actually happen as it siply stores a capture of the screen in memory. You need to paste it into something. The easiest way to do that is fire up MS paint that every Windows machine should have. Either find it under "All  Programs - Accessories" or go to the Start menu, select "Run" and type in "mspaint". It should fire up a simple painting application. Select "Edit" and "Paste". The screen should now appear in the program window. Now save the image by selecting "File -> Save as" I'd suggest saving it as a JPEG rather than a BMP (this isn't a problem in newer versions of windows)
 
You can get additional software such as "greenshot" that does a better job, and Windows 7 and beyond comes with the "Snipping Tool" but the method outlined above works on everything Windows and usually is the simplest method.

By Primitive Designs

When you just want a web browser...

So recently I lent someone a LiveCD of Linux to help them get round a trashed computer. As far as I know they are still using that! Linux used to be complex and hard to learn (but very powerful) now you can get running with it in minutes. Android is based on it. So what's a LiveCD and how would it benefit you to have one? Well basically it's an installation of an operating system on a CD or DVD. The idea is you boot your computer from it and as long as you have a fairly normal home set up you can get straight onto the internet. You would use it in the following situations -

1: You've got a virus or something is broken on your Windows install.
2: You're letting your kid brother/nephew/niece/other on your computer and you don't want them installing aforementioned virus.
3: You're worried about what's in your browser history.

For the first reason alone it's worth having a disk like that handy. Simply download an ISO file and burn it to a blank DVD/CD. You may have to learn how to boot the computer from the CD drive but that's normally hitting something like "F11" when the machine is first switched on. Check the messages on the screen when you hit the power button. There are lots of Live CD's out there. I'd recommend two. Firstly there's Mint.

http://www.linuxmint.com/download.php

Select the "32bit" Cinnamon version if you've got a newish PC. It's pretty and nice to use.
Alternately if you just want something really simple download EasyPeasy

http://www.geteasypeasy.com/get-easypeasy/

Just download the ISO file and burn it to disk. Don't bother with the USB stick installer unless you want to use that to boot from instead of the CD. It gives you a very easy to use system. It won't have much installed but lets face it most of the time all you want is a web browser!

By Primitive Designs

Something nasty happened and need to reboot?

I've got a server which something nasty has happened to. The filesystem is giving me errors and although I can log in to ssh (it's loaded into memory) I can't run any commands. Now normally I'd copy off what I could and plug in a rescue CD. However in this case I think it might have been a temporary issue and all I need to do is reboot. How do you reboot if /sbin/reboot isn't available? Simple -

echo 1 > /proc/sys/kernel/sysrq
echo b > /proc/sysrq-trigger


In this case I think I knocked the SATA cable on the live running system. Stupid I know but these things happen. If it really is a disk problem then you're better not rebooting I guess, unless you can get a rescueCD put in the machine first of all!

By Primitive Designs

Openwrt is a viable replacement to expensive hardware!

Current project is OpenWRT. Definitely for the more technical type but if you have some patience it's a wonderful thing to run. I've not tried it on the actual ADSL connection itself but works really well as a wireless router. the important thing to check is first if your device works with it and second how much flash memory it has. My first router only had 4Mb of storage which is enough to install what your current router does but not a lot else. If you want to seriously muck about with it you need to be using something like the Buffalo WZR-AG300H.
If you've dipped your toes with a Raspberry Pi it is the next thing to look at. Just don't run it on your primary ADSL router till your certain it supports it. Otherwise you might have bricked you hardware. Also start with the 10.03 version.

 

By Primitive Designs

Music Player Pi

OK so at long last I've written up my notes on installing a headless music player on you Pi. It's a nice little way to have music playing without using you PC to do it. If you can then get the wireless bit working you could put this anywhere in your house and connect to it using your phone!

Apologies for the text being a little weird looking. I formatted it using a word processor then imported it into the web site. Always a bad idea!!! If people want I'll turn it into a more readable PDF too...

You can read it here

By Primitive Designs

Email is the new Facebook

While most people have fully embraced Facebook and use it to organise their social calendar there are some people out there that don't. For them a mailing list might be useful. Basically a way a lot of people can exchange messages between themselves without having to type in 20-30 email addresses. I'm now offering this to anyone who needs it to share views or ideas by email. You get to decide who's on your list and can kick them off if you want! The system also makes an archive of old messages so you don't need to. I'm using my "infomates.co.uk" domain to do this so you end up with an address like "glasgowclubbing@infomates.co.uk" or "potteryclass@infomates.co.uk". Drop me a line if you are interested. Things like social gatherings, clubs and associations etc. are what I was thinking of but anything goes here!

By Primitive Designs

Sona Photography signs up to Primitive Designs

This week we've signed up Sona Photography for a website and hosting account. As before I used Pixie CMS to give them a clear and easy to update website. You can see their website here.

By Primitive Designs

A domain by any other name would smell as sweet...

Today I thought I would tackle a slightly different area and delve into the mysterious world of internet domains. They’re not actually that mysterious actually and quite straight forward but tend to confuse a lot of people, not least because different people use different terminology for the same concepts.

You get up in the morning pop on you computer and go your favourite website. Lets say www.facebook.com. You just type that in the URL bar and a webpage just loads magically right? Well yes, but it’s not actually magic.

First of all your computer reads what you’ve typed in “www.facebook.com”. It then splits that up into a server and a internet domain, a bit like you might split up someone’s street address into a number and a street name. It figures out it is looking for a computer out there called “www” under the internet domain “facebook.com”.

You see the first bit of a URL actually points to a physical computer out there somewhere. Sometimes that computer can be known under different names but i’ll come to that later. The internet domain part is not really a physical location as such it just identifies under who's jurisdiction this server comes under. It knows that somewhere out there is a computer that can tell it the way to all the other computers that end facebook.com. In fact it first of all has to look up “.com” and figure out who to ask about facebook from there. Once it’s worked out who tells it about computers ending “facebook.com” it asks it where www is. That computer will tell it an IP address which is what it actually connects to. In this case 69.171.242.54. IP addresses are what the internet really runs on but most people don’t want to remember things like “69.171.242.54“ or “74.125.39.99“ - it’s easier to remember things like www.google.com than a random list of numbers.

You may also notice there is a lot of to and fro-ing going on there just to get to a webpage, and you’d be right. The point is that internet technology is very decentralised. Part of the reason for this is that it means that the failure of any one computer doesn’t cause catastrophic damage (it was designed to withstand nuclear attack!!!). Anyway all this traffic is very small and only takes a second.

Once your computer has looked up www.facebook.com (or as you could call it the computer “www” that sits under the jurisdiction or “facebook” under the jurisdiction of the “.com” domain) it remembers where it is for next time so it doesn’t need to look it up again for a while.

The other point here is that “www” is a completely arbitrary name for the computer. If it was called “chickenkiev” then you could point your web browser at “ckickenkiev.facebook.com” and it should show you a webpage. It doesn’t need to be called www.... it is just that that has become the accepted standard for webservers and the thing everyone types in.

Now what if you want your own website? How does that all work? Well as you can hopefully see from the above what you need to have a website “www.greatthings.com” is actually two things - firstly you need to be able to tell people about computers that end “greatthings.com” and secondly you need a computer out there called www.

In fact these fall neatly into two completely different services - usually referred to “Domain name” control and “web hosting” accounts. Often you will buy both of these from the same person (I offer both for example) but you don’t have to. Buying a domain name is something you do though a domain name registrar such as “123-reg”. You choose your domain (the greatthings.com bit) and pay an annual fee for holding onto that domain. While you pay for it no one else can use it so it is a good idea to register domain names you want to protect even if you don’t actually have a website to host yet. The website hosting part usually involves renting a bit of space on a computer connected to a very fast internet connection and putting up your web pages (which are just a set of files) onto that computer. For big sites companies have their own computer, but that’s an expensive option and for just half a dozen web pages renting space on a shared computer is the way to go.

When you have both these things you have to point the www entry for your domain at this computer. That lets the internet know where it can find your website. Usually this is done though a web page you can access when you signed up for your domain name. If you had your web page designed by a web developer (rich are you???) then they normally take care of this for you, but they still need to set up both aspects I’ve mentioned. It’s worth remembering that the domain name - “greatthings.com” for example - should be registered under your name, and that even if you subsequently fall out with your web developer, you legally own the right to do what you want with it - including pointing the “www” bit at another website.

So there you go. All much clearer? Incidentally Primitive Designs offer both purchasing domain names for you, and will host websites. All with advice and at competitive rates! Get in touch if you want to know more...

By Primitive Designs