Wake-on-lan (WOL) bash script on router running dd-wrt

After setting up my router to run dd-wrt I’ve used PuTTy to ssh into the router to start my desktop machine to work on it through a RDP session.

After spending months looking up the correct MAC address in my phone and typing the commands by hand I finally took a bit of time to write a small bash script on the router so that I could simply run the script each time I needed it.

On my router (WRT54GL) there’s a bit of space in the /jffs folder that’s usable for storing scripts.

To write a script named “wol” go to the correct directory and type:

vi wol

VI opens in command mode. To start editing press the INSERT key. At the bottom left of the screen a “I” will be displayed. The editor is now in editing mode. I just wrote:

#!/bin/ash

echo “Waking up 19\” system”

/usr/sbin/wol -i 192.168.100.255 -p 9 xx:xx:xx:xx:xx:xx

echo “Done”

Where xx:xx:xx:xx:xx:xx is the MAC address of my network card.

To get back in command mode press ESCAPE.

Then to save the file and exit type:

:wq and ENTER. (the semicolon starts the command, wq stands for write and quit).

This creates the script, the only thing left is to make is executable:

chmod 700 wol

From now on, the script can be started by going to the correct directory and typing:

./wol

The script will be called and run the commands. If there are any error messages they will be displayed.

Ubuntu Server – setting up ZFS (part 1)

For a while I’ve wanted to learn about Linux, the way the OS works, what can be done with it, if it’s reasonable to change to it as my main operating system.

As well as dual booting Windows 7 and Ubuntu 12.04 on my laptop I thought I should try and set up my home server running a Linux distro. This way I’d be forced to learn my way around the command line, setting up a system to run smoothly without the need for much maintenance.

The things I wanted to try to set up were:

  • Some sort of NAS, with the option of mounting it as a samba drive over my internal network and using some sort of FTP that has to be secure when accessing the shares from outside of my home network.
  • I really want to give Owncloud a try. Not just as an alternative to Dropbox, but also as a central calendar and contact database. Over WebDAV that should be possible. I’ll have to get a basic Apache setup running to do this.
  • I’d like to try out the ZFS file system as I have no previous experience with it.
  • To have an openVPN server running at home would be nice when working abroad for longer periods of time (tunneling email, accessing home network, …)
  • Maybe a Socks proxy (?)
  • Keeping it all secure

As I have some experience with Ubuntu desktop I picked Ubuntu Server to start with. As I go along setting up the system I might end up deciding to pick something else and start over, but as I take this as a learning experience that’s fine.

So I started downloading the Ubuntu Server 12.04 AMD64 iso and made a bootable USB stick to install the system.

During the installation I didn’t change much from the standard settings. I partitioned the disk before installing the OS but nothing else. As I knew I was going to need the Apache and MySQL packages for Owncloud I picked the LAMP bundle for installation as well.

After installation one of the first things to do was to get a zfs pool up and running. I had picked two Western Digital RED series 2 TB disks as my data disks as they are made to be running for extended periods of time and one Seagate Spinpoint 320 GB 2.5″ drive for the OS and swap. This should give me a good balance between power and storage. The 2.5″ will be set up to go into idle really quick to save power.

Installing Ubuntu ZFS

To install the ubuntu-zfs package the ppa:zfs-native/stable repository needs tot be added to the system.

Apparently the add-apt-repository command wasn’t installed yet on the 64 bit version on my system. There are two options:

  1. Install the python-software-properties package
  2. manually add the repositories to /etc/apt/sources.list

As I will need to add more ppa’s later on I chose the first option.

A quick sudo apt-get install ubuntu-zfs and some 170 Meg later the package was build and installed.

Creating a ZFS pool

sudo parted followed by print devices displays a list of devices with their storage capacity:

(parted) print devices
/dev/sda (320GB)
/dev/sdb (2000GB)
/dev/sdc (2000GB)

/dev/sdb and /dev/sdc are my two disks that will be used for a mirrored ZFS pool.

sudo zpool create zfs mirror /dev/sdb /dev/sdc creates a mirrored pool named zfs using the two disks in a mirrored configuration. Instead of residing in the /media or /mount directory, it can be found in the root of the file system.

sudo zpool list confirms that the pool exists:

NAME   SIZE  ALLOC   FREE    CAP  DEDUP  HEALTH  ALTROOT
zfs   1.81T   496K  1.81T     0%  1.00x  ONLINE  –

The next step will be to test the pool, writing data to it, unplugging one of the disks, formatting it, adding it to the pool again and check if everything works as fine as it should.

Before doing that I’ll set up a samba share on the zfs directory. This will provide me with a real-world situation where I can access the pool from another computer in my network.

Dive light rebuilding

About two years ago I bought a Hartenberger “Maxi Compact” dive light for about €60.

As this was a 10 year old dive light with a halogen bulb and a well-used battery pack I think that was a fair price. Anyway, the plan was to use the housing for a modded LED light.

At first I just made a second battery pack, the first one was just (not) enough for one dive with the original bulb, so I needed a second one and charge one pack while diving with the other. Also bought a Graupner “Ultramat 14 Plus” battery charger as this was an affordable charger that can be used for a variety of different chemistries, but best of all, it has a port that allows for cell balancing. As I was using a 6S NiMH battery pack, that was a feature I wanted to have.

A couple of weeks ago I started making the LED module with driver, heatsink and connections to the battery pack. The original idea was to hack into the driver circuit that delivers the PWM to the original bulb as I could use the original on/off/dim switch at the back of the light, but I didn’t get there yet…

So. Starting with the heatsink. I couldn’t find a 62mm aluminium rod that I could use to turn the heat sink from (inner diameter from the housing), but I did find a scrap 5mm plate. Decided to try with two layers of that.

First drilled out a circle with a drill press, trying to keep it as round as possible.

Dive Light 1

Drilled a hole in the middle to allow a 8mm bolt (started with 5mm but clearly wasn’t strong enough for the coming abuse) to put the piece in the chuck of the lathe and two extra holes for 4mm bolts to make sure the two parts wouldn’t rotate but stay together nicely .

With the piece in place fired up the lathe and started grinding the rough parts with a metal file. When the piece was round enough -about 1.5 hours later- started off with the lathe, turning off really small pieces at a time. Never thought using a lathe was so much fun. I’ll come up with other ideas just to use the lathe again.

Dive Light 2

Ended up with this, rather happy with it:

Dive Light 3

Designed a drawing in Autocad for the driver, led modules, optics and wire holes and drilled them. Countersunk the bolts where necessary.

Dive Light 4

Rough positioning to check if everything fits.

Dive Light 6

With only a limited time before leaving on a dive trip I bought the driver circuit from Led-Tech as they could get me the parts quick enough. I wanted the warm CREE’s as their colour reproduction is better: CRI for CREE XM-L cool white is 65, CRI for neutral white is 75. There’s also a special warm white XM-L with a CRI of 90. Obviously hat would be the one to go for.

The battery pack delivers 4200mAh’s at 7,8 volts max, and the original idea was to drive 3 XM-L’s at 1200 mAh’s as that seems a sweet spot between power consumption, heat production and light output. To do so I’d need a boost converter (the leds have a 3.05V drop at 1200 mAh, so 9.15V nominal) but Led-Tech only had buck converters. New plan: drive two leds at 900mAh, use the light in a real-life situation for a number of times and see what the light output is like.

Dive Light 5

Dive Light 0

As I didn’t manage to hack into the PWM driving circuit (which had a feedback loop that relied on the halogen bulb and didn’t play nice with the constant current driver circuit), I just added a reed switch that I found in my parts bin. No holes that can cause leaks under water, just a magnet outside the housing to switch the light on/off.

Dive Light 7 Dive Light 8 Dive Light 9 Dive Light 10

Comparison with a 1000 lumen dive light:

Dive Light 11 Dive Light 12

And finally:

Dive Light 13

After about twenty dives with the light I realised that 3 XM-L’s at more than 1000 mAh would be overkill. Also, the optics that I used now are to wide. Nice in clear water, but as soon as there’s a bit of sediment there’s too much reflection. I might keep these optics on one of the XM-L’s, and give the other two a narrower beam. I’d need some kind of control to choose between the two and also a dimming circuit but that’s for later.

Really happy with the power consumption. Where I couldn’t do a single dive without the light getting dimmer at the end of the dive when using the halogen, I can now easily do 3 long dives without charging.

I’ll have to work on the connectors as well. Cramming an 7-pin connection on the battery packs, a connection between the front and the back (where the switch is), a connection between battery pack and the driver while keeping it all easy to open up for charging will take some thinking.

So far, I’m happy with what I have right now and *really* loved the lathe.

Recent projects

So.. After a diving trip it’s about time to write up on two recent projects:

  1. Home server: As I wanted to get into Linux for a long time and also wanted to set up a home server for VPN/SSH/FTPES/firewall/my own Exchange replacement and sharing of music and movies in my own network (and remote, of course), this seemed like a good time to dive in. Starting with a generic Ubuntu server package without GUI I’ve started setting up a low power system that I can leave on permanently without having to worry about it too much. A good opportunity to read up on current computer hardware as well.
  2. Dive light: a while ago I bought a halogen dive light with the idea of using the housing for a diy LED dive light. Benefits: light output, can choose my own beam characteristics, longer runtime. Drawbacks: colour reproduction. Pretty much still a work in progress, but I’ve done about 20 dives with a system with 2 XM-L’s driven at about 900 mA’s and easily lights up the beachfront after a night dive. Also: first time working with a lathe.

More about these two soon.

Mares Dragonfly BCD cleaning/modding

Warning: salt, corrosion and dirt up ahead:

Image

Since I began diving about two years ago I’ve mostly rented gear whenever I needed it.
What I like about renting things is that you get to try different brands and models, and little by little start finding out what you like/don’t like/need/want/hate about certain gear.  You also get some time to figure out how things work and what kind of preferences you have.
Diving equipment isn’t cheap, but taking time to shop around can get you a significantly cheaper set of gear.

A while ago I got hold of a second-hand Mares Dragonfly semi-wing jacket for €80.
Even though it seemed in good shape, I wasn’t sure how well the previous owner took care of it so I wanted to thoroughly clean it. And of course, in all honesty, just wanted to take it apart to see how it was made and how things work.
A service manual would have been nice, but I couldn’t find it for this jacket. I did find some exploded views in the “01 revision of the Mares service manual that’s floating around on the internet, but no guidelines. Well then… Off we go.
First I took a look at the dump valves on the right shoulder and the lower right side on the hip. They came off easily just by turning them counter-clockwise, as one would expect.
There’s just the outer plastic cap, a spring, a plastic piece that holds the rubber and the rubber seal that seals off the port. Pull the cord and the seal moves away a bit from the port. Overpressure inside the jacket puts enough force on the rubber from the inside to overcome the pressure from the spring and open until the pressure is below the threshold.
The rubbers are not glued onto the plastic caps, there’s just some kind of grease. I left that on, but cleaned the underside of the rubber seals from dust and patches of salty build-up. I didn’t take any pictures before the cleaning, only afterwards.
While they were open, I gave everything a rub, and got out the spray paint. Why not touch them up a bit again and make my jacket more recognizable?
Also replaced the dull black cord with some cord from my rock-climbing stash of cords.

This jacket has one big downside and that’s the weight. Close to 4 kg it’s really heavy when travelling by plane. I have been looking where I could lighten things without touching the main functionality of the jacket. I’ve tried replacing one of handles/weight on one of the dump cords with a ping-pong ball. My only concern is (ironically) the lack of weight. While it can fill up with water, it has no weight in itself so I’m not sure if it won’t float around too much while diving. We’ll see.

While, supposedly, you need a special tool to open the plastic ring that seals the airtrim thing on your left hip to the jacket (same for the valves itself) I opened up the console. An exploded view can be found in the Mares manual p. 102, drawing J83.
The console opens up after unscrewing the three screws on the outside. Mind you, these are machine screws without bolts. They’re just screwed into the plastic so treat them accordingly.

Jacket Mares Dragonfly pimping_26aug2012_0025_resize

The system is a white plastic thing that comes off after unscrewing the two visible screws. There’s one big O-ring inside to seal it off. That’s all there is to it. The connector to the hose that feeds the two valves stays on the jacket, it has an O-ring and just slides into the white plastic. (pictures are after cleaning)

Jacket Mares Dragonfly pimping_26aug2012_0022_resize

Jacket Mares Dragonfly pimping_26aug2012_0015_resize

The connection to the low pressure feeding hose screws out of the plastic (14mm key), and so do  the two buttons (both 17mm key). They both have another thread, so there’s no mistake possible while assembling them again. Jacket Mares Dragonfly pimping_26aug2012_0020_resize

Inside the hole where the low pressure feeding hose connection goes into is a small plastic filter to keep contaminants out of the system. Make sure it stays in there. The inflate button assembly comes apart into its separate pieces, but for the dump button construction to come apart you need a 6mm and a 5mm key. The centre piston is in two parts, and must be unscrewed. The upper part comes out from the top, the lower one slides out to the bottom.

Jacket Mares Dragonfly pimping_26aug2012_0007_resize

To me, the O-rings all seemed in good shape, so I didn’t search for replacements. If that would have been necessary I’d probably just would have taken the jacket to a shop for maintenance.
I cleaned everything with a lots love, warm water and some vinegar. I’m not sure if that’s the best way, but it’s the best one I found.

Jacket Mares Dragonfly pimping_26aug2012_0023_resize

I gently tried to open the “special” bolt that needs special tools. An owner of a dive shop showed me this “special” tool and it seemed to just be a cup-like mould that slides over the bolt to get more grip on it. The thing didn’t move however and I really didn’t want to break anything. It would only need to come apart to satisfy my curiosity so it isn’t worth breaking it.

Everything was reassembled and put back on the vest. The plastic parts outside got a scrub and some layers of paint.

The jacket isn’t any better now, but at least I’ve seen the inside of the system, it got cleaned out and the visible parts got a cosmetic touch-up. I also cleaned and did some small changes to the manual inflator hose, but that’s for an other time.