Primitive Blog (Tag: linux)

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

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

MythTV as a home media Player

Do you want a simple media player/viewer for the home? Maybe a device that you can watch videos on, view family snaps or just listen to some music? There are a lot of custom devices out there but maybe you should try MythTV! Although it's geared up to work with TV tuner cards it will happily work without one and allow you to share files throughout the house using Samba and UPnP as well.

I'd recommend using Mythbuntu. Note the latest version of Mythbuntu includes MythTV 0.24 which bringing in a few differences to the program, not least removing DVD ripping facilities. If you are building a home media station with this in mind you may wish to go for an eariler disk. All the older versions are still available on the site by selecting the "Advanced" button when you download the CD. I'd recommend the 10.04 version as it still includes Ubuntu packages that will be officially supported under LTS.

By Primitive Designs