Archive

Archive for the ‘Guides’ Category

Building an email server using ClearOS

August 5th, 2010 Jonathan No comments

I’ve had a server at home for years now, and I’ve also been a professional sysadmin for at least three years. I know my way around Linux pretty well and for some time I’ve run my own web server and also other services.

But one thing I’ve steered clear of until now is running my own email server.

I’ve always thought it would be fairly easy to set up, but much harder to make secure. I don’t want to receive tonnes of spam and I don’t want spammers using my SMTP server as an open relay. In the past I’ve read about building SMTP servers with sendmail, postfix and exim but there was all sorts of conflicting information when it came to integrating milters and so on. Different guides all seemed to give contradictory advice and require all sorts of strange configuration steps that I couldn’t understand.

But all that changed when I heard about ClearOS. In short, it’s a spin of CentOS which uses a custom web interface to configure various software “modules”, including things like web server, email server, firewall gateway, database server, and so on.

I installed it on a virtual machine and after only a few clicks I was running a mail server: an MX for receiving mail for my domains, an authenticated SMTP server for personal outgoing mail, and a secure IMAP server for storing and accessing my mail. The frontend sets up postfix and cyrus to do its dirty work.

For ultimate ease, users (just me, in this case) are authenticated using a local LDAP directory, rather than by using system accounts. All SSL certificates for IMAPS and HTTPS were added automatically. Email antivirus scanning is done by Amavis and spam filtering is done by Spamassassin.

I had a little bit of trouble setting up Horde to access webmail and a web interface for configuring sieve rules. By “trouble” I mean the default Apache virtual host declarations needed some changing around and some aliases adding. If you’re familiar with Apache this won’t be a problem.

There are some aspects of ClearOS I don’t like so much, and I would prefer to use CentOS. But now ClearOS has written out all my configs it should be trivial to move my new mail setup to a plain old CentOS installation, where I already run my websites from. I have definitely learnt a lot about how email works by simply reading and understanding the config files written by the frontend.

So if you want to build an email server but don’t know where to start – try ClearOS. It’s a great introduction to the “scary” parts of setting up an email server, like milters and certificates.

Converting 120 film to 620

June 26th, 2010 Jonathan No comments

Recently I was lent a Kodak Six-20 Brownie box camera. Rather than the 120 medium format film I’ve used in the past, it takes 620 film.

The film stock is identical; only the spools differ. The 620 spool has a thinner axle, the end caps have a smaller diameter by about 2mm, and  the overall length of the entire spool is about 2mm shorter.

Original 120, 620 and modern 120 film spools with modern 120 film

120 film is still readily available but 620 film is very hard to find. There are two options:

  • Buy some empty 620 spools, and respool the 120 film in a darkroom
  • Modify the 120 spool of each new film by filing it down

I find roll film quite frustrating to work with in a darkroom and I didn’t fancy respooling it unless there was no other choice. So I decided to have a go at butchering a roll of 120. Even if it went wrong, I’d only have ruined £4 of film.

With the film still on the roll as new, I filed down the fatness of the end caps and then filed down their diameter. Fortunately I had one empty 620 spool to use as a template for my hack. It took only about ten minutes, but obviously filing away plastic left a lot of dust, so I had to make sure the film was extremely clean before putting it in the camera. I brushed it, and sprayed it with a can of compressed air.

The film now fits nicely into the Brownie, and I look forward to shooting with it. :)

Categories: Guides, Photography Tags: , , , , , , ,

Calibrating the focus ring on a Paxette

June 11th, 2010 Jonathan No comments

Recently I was given a Braun Paxette. After running a couple of rolls of film through it, I’ve decided that the focus isn’t quite calibrated correctly according to the focus ring.

Fortunately, you can loosen three grub screws around the snout of the lens and rotate the focus ring without moving the lens, line it up properly, and tighten it up again.

To calibrate the focus, you will need:

  • a bright and high-contrast object a known distance from the camera
  • some tracing paper or other diffuse translucent material

And here’s how we do it.

  1. Set up the camera on a tripod with the back open/removed. Attach the tracing paper where the film would usually go, like so:

    Calibrating a Paxette

  2. Put your bright object a known distance from the camera, and measure it. Call this distance X. If working indoors, try using something like a desk lamp or a TV screen (both are bright, with strong edges). If working outdoors, you could use a building with strong features (and pace out the distance from your camera).
  3. You might need to cast a shadow over the paper to see your image, but it should be there, albeit upside down.
  4. Focus the image so it is sharp. It can be hard to tell if the image is sharp, so you could use a magnifying glass to inspect it.
  5. When you’re happy that the image is in focus, you know that whatever your focus is set to now is X. Loosen the focus ring, readjust to that value, and tighten.

You’re done! Happy shooting.

Categories: Guides, Photography Tags: , , ,

Newbie’s guide for Linux Apache web servers

June 3rd, 2010 Jonathan No comments

Today a friend (from a Windows background – still a friend?! :P ) asked me how to go about setting up a LAMP (Linux, Apache, MySQL & PHP) server. I wrote him a few notes, not only on how to configure the LAMP stack, but also on how to configure a Linux system properly from scratch, and how to do so securely. There are millions of guides out there that explain how to serve web pages with Apache, but not many of them explain the basics of setting up a secure system too.

I’ve edited these notes slightly to make them suitable for a wider audience, but in essence it’s the same stuff. Hope it’s useful!

OS installation

I recommend using CentOS. It doesn’t really matter whether you choose 32-bit (i386) or 64-bit (x86_64) but use ideally use 64-bit unless there’s a reason not to.

Boot from the CD or DVD of your choice. It doesn’t matter whether you use the full DVD, or the network install CD.

Choose the text-based installer from the boot prompt by typing linux text. The text installer doesn’t install as much extra rubbish as the GUI installer.

In most cases the default options are good enough. One option you should change is to use an NTP time server. This is especially important with virtual machines, since they suffer badly from clock drift.

Choose a strong root password. You will only need it once again. After that, you won’t even even need it for logging on, so there is no need to pick anything memorable. In fact, you are best off choosing a long, random string of mixed-case letters and numbers.

When it comes to choosing packages, deselect as many of the groups as possible. We will add the packages we need individually later on.

Let the installer run its course, and reboot.

Users and passwords

Upon first boot, log in as root using the password you picked before. Now create new user accounts and set passwords:

useradd yourusername
passwd yourusername

Now for setting sudo access. This is like “run as admin” on Windows. Type visudo. In the text file that opens, read down to the line that says

root    ALL=(ALL)       ALL

Duplicate it twice by pressing yyp. Go into insert mode by pressing i and change the username root to your username. When you are done, hit Esc and type :wq to save and exit. Gotta love vi commands ;)

To disable remote root login via ssh, edit the file /etc/ssh/sshd_config using your favourite editor. If you don’t already have a favourite editor, use vi.

Find the line:

#PermitRootLogin yes

and uncomment it and change the value to no:

PermitRootLogin no

Restart the ssh daemon by doing

sudo /sbin/service sshd restart

From now on you can gain root access by using the sudo command, and you won’t need to log in as root again. Log out now by typing exit and re-login as your own user. Forget the root password forever.

Installing packages

First we add a couple of third-party software repositories that have useful stuff.

sudo rpm -Uvh http://download1.rpmfusion.org/free/el/updates/testing/5/i386/rpmfusion-free-release-5-0.1.noarch.rpm http://download1.rpmfusion.org/nonfree/el/updates/testing/5/i386/rpmfusion-nonfree-release-5-0.1.noarch.rpm

Let’s get rid of the stuff we don’t want or need. There are no doubt more than things that can be removed than I’ve listed here, but they can be removed later.

sudo yum remove bluez* pcsc*

Update the system so you’re sure that that latest versions of all software are installed.

sudo yum update

Now we can install the stuff we want for LAMP!

sudo yum install httpd mysql-server php php-mysql

If you are wanting to use any PHP modules/libraries they can be installed here too, such as the commonly-used graphics library gd.

Services

Let’s start the two daemons for Apache and MySQL, and tell them to start on boot.

sudo /sbin/service httpd start
sudo /sbin/service mysqld start
sudo /sbin/chkconfig httpd on
sudo /sbin/chkconfig mysqld on

Apache in its default state will run out of the box. MySQL just needs a root password setting.

mysqladmin -u root password NEWPASSWORD

From now on it’s advisable to GRANT access to specific users on specific databases/tables. Go read about MySQL users.

Firewall

Let’s assume you want HTTP on port 80 open to the world. Open /etc/sysconfig/iptables for editing, and add this line.

-A RH-INPUT -p tcp -m tcp --dport 80 -j ACCEPT

Save and close, and run this to make the changes live.

sudo /sbin/service iptables restart

Editing configs

The main config file for Apache is at /etc/httpd/conf/httpd.conf. It doesn’t need any changes for basic operation, but if you edit it you need to restart the httpd service to pick up the changes.

If you get serious with web publishing from a LAMP platform, you will probably want to read about name-based virtual hosts.

Adding content

In its basic configuration, you should add PHP scripts, HTML pages and other content like images and stylesheets to /var/www/html/. You do not need to restart the daemon for it to pick up new content.

When debugging pages, you will probably find it handy to refer to the error log, at /var/log/httpd/error_log.

Tip: Open two SSH windows to the server – one for editing stuff, and the other for watching the log scroll by as events occur. Use Ctrl-C to break out of it. Do this:

sudo tail -f /var/log/httpd/error_log
Categories: Guides, Linux, Networking, Web Tags: , , , , ,

Tilt-shift miniature fakes in GIMP

May 3rd, 2010 Jonathan No comments

As posted on my photo blog yesterday, I faked a tilt-shift miniature model of the A4 in the Avon Gorge.

I’d never tried it before, so I followed this guide on how to do it. It was pretty straight forward, but I’ve recreated the steps here, with my own modifications.

Step 0: Take a photo

Start off by taking a photo to make into a fake miniature. The best photos are taken looking down on your subject, as a human observer would see a model on a table, for example. Include subjects such as people or cars to give a sense of “scale”.

Strong shadows also lend themselves to the effect, as you may well look at a model railway using a single desk lamp, for example.

Step 1: Adjust colours

Most models have more vivid colours than real life, due to their glossy paint. There are several ways you could achieve this.

  • Go to Layer > Colors > Curves. Click at about x: 130 y: 210. Move the curve around until you get what you are looking for.
  • Or, go to Colors > Auto > Color Enhance. This is the lazy man’s way of boosting the saturation.

You might also like to enhance the contrast to make the shadows stronger.

Step 2: Set gradient mask

Open the image and toggle the switch mask on. There are three ways to do this:

  • Click the dotted box in the bottom left had corner of the open image, or
  • Got to Select > Toggle Quick Mask, or
  • Press Shift+Q.

The image will now be pink. Click on the Gradient tool. It looks like a square with a grey gradient applied to it. Set the gradient shape to Bi-linear.

Step 3: Apply mask

Pick your focal point. Decide what areas of the image you would like to be in or out of focus. Click in the center of the area you would like to be in focus and drag a line perpendicular to the direction you want to be masked, i.e. dragging the line from the “in focus” region to the “out of focus” region.

Play around with the centre, size, and angle of the mask until you get what you are looking for. Toggle the switch mask off.

Step 4: Apply blur

GIMP doesn’t have Lens Blur like Photoshop (although it can be installed). We have to make do with Gaussian Blur. Go to Filters > Blur > Gaussian Blur. In the Gaussian Blur window click on Preview and maximize the window so that you can see what you are doing.

Play with the blur radius until it looks right. A Blur radius between 5.0 and 10.0 seems to work most of the time, although I found a radius of 50.0 was needed to achieve a decent effect in my image. It depends on the resolution of your camera.

When you have the blur right, delete the quick mask by going to Select > All.

Categories: Guides, Linux, Photography Tags: , , , ,

Getting information about your video files

February 16th, 2010 Jonathan No comments

The other day, I wanted to find out which of the videos in my movie collection were encoded with multitrack (e.g. 5.1) sound.

I found a tool for Linux called themonospot. Happily, it’s packaged with Fedora and can be installed simply by doing

yum install themonospot-console

Once installed it’ll quickly give you information about your video files:

[jonathan@zeus ~]$ themonospot-console /media/public/Movies/Sunshine/Sunshine.avi
File path:               /media/public/Movies/Sunshine/Sunshine.avi
Codec name:              XVID
Codec desc:              xvid
Frame size:              704 x 288
Average video bitrate:   1,423 Kb/Sec
File size:               1,525,886 KB
Total time:              01:47:26.00 seconds
Frame rate:              24.00 frames/sec
Total frames:            154,574
Video data rate:         23 frames/sec
Video quality:           113
Packet Bitstream:        False
ISFT data:               VirtualDubMod 1.5.10.2 (build 2540/release)
JUNK data:               VirtualDubMod build 2540/release
USER data:               XviD0046
Audio 01:                0x2000 (AC3) 448.00 Kb/Sec - 48000 Hz (6 Channels)

As you can see, my copy of Sunshine has 6-channel audio (i.e. 5.1). But what if you want to run a batch job to check all of your films and see which ones have surround sound?

Then use perl.

I wrote an extremely hacky script that takes a path as an argument and whizzes round to fetch the encoding of all .avi or .AVI files in the directory. It prints the names of any that have more than 2 audio channels (i.e. better than stereo).

It sometimes goes wrong if the output of themonospot-console varies, as it occasionally does.

So you get output like this…

[jonathan@zeus ~]$ ./findAudioEncoding.pl /media/public/Movies/
/media/public/Movies/Catch Me If You Can/Catch Me If You Can.avi : 6
/media/public/Movies/National Treasure - Book of Secrets/National Treasure - Book of Secrets.avi : 6
/media/public/Movies/Never Been Kissed/Never Been Kissed.avi : 6
/media/public/Movies/Rescuers, The/Rescuers, The.avi : 5
Argument "" isn't numeric in numeric gt (>) at ./findAudioEncoding.pl line 12.
/media/public/Movies/Brideshead Revisited/Brideshead Revisited.avi : 5
/media/public/Movies/Passion of the Christ, The/Passion of the Christ, The.avi : 6

If you’re interested in the source, here it is. If you find this useful, why not “like” my post? (The at the bottom)

#!/usr/bin/perl -w
# findAudioEncoding.pl

use strict;
my $path = $ARGV[0];
chomp (my @files = `find $path 2> /dev/null | grep -i .avi`);
foreach my $file (@files) {
        chomp (my $channels = `themonospot-console "$file" | grep \"Audio 01\" | awk \' { print \$10 } \'`);
        $channels =~ s/\(//g;
        if ($channels > 2) {
                print "$file : $channels\n";
        }
}
Categories: Guides, Linux Tags: , , , ,

CameraTutor

January 4th, 2010 Jonathan No comments

My friend Stu (former organiser of the Photo Challenge and professional photographer based in Leicestershire) has recently launched a photography tutorial website called CameraTutor. There’s not much more I can add other than this info from the site itself, and my encouragement to follow the blog if you are interested in photography yourself.

Starting on the 1st of January, 2010 will be a series of photography tutorials to help you get the best from your camera – it doesn’t matter if you have a top-of-the-range SLR or a point and shoot, there should be something for everyone here. A new tutorial will appear each Friday morning, giving information on a single technique, concept or other thinking point. I hope not to make anything too complicated, and welcome questions and comments on each post in the comments section.

So come along for the ride – I hope I will learn from you as much as you will learn from me, and we can all improve together.

Categories: Guides, Photography Tags: ,

Taking screenshots on an Android-based phone

December 10th, 2009 Jonathan 2 comments

Yesterday I got an Android-based smartphone (an HTC Magic). Today I want to document some of its features, which also includes taking screenshots.

Unfortunately there is no way of taking screenshots with the provided software, and the only screenshot app in the Market requires you to have a rooted phone.

I eventually came across this guide which explains how to take screenshots using a PC and the Android SDK. However not all of the steps are necessary so I’ve prepared a slightly simplified version.

  1. On your Android phone, go to Settings, then Applications, and then Development. Check the checkbox to enable USB debugging.
  2. Download the Android SDK for your platform here.
  3. Unzip the SDK in a convenient location.
  4. Run the DDMS program from the tools folder, inside the folder that you just unzipped.
  5. Plug your Android handset into a USB port on your computer, if it is not plugged in already.
  6. You should see your Android phone appear in the top-left pane of the program. Select it.
  7. Click on the Device menu and choose Screen capture.
  8. From the box that pops up, you can see what’s on your Android device and either save or copy the screenshots.

Christina Warren goes on to say:

There is a caveat: Because your device has to be plugged into USB to be accessed by the SDK, the SD card cannot be used for taking photographs, playing music or downloading music from the Amazon.com MP3 store. You can take pictures of some of those screens, but to actually download anything, take movies, or take a photo, you cannot have your device plugged into the computer and accessed by the SDK.

I can’t comment on that – like I said, I’ve only had the Magic since yesterday and I haven’t tried much on it yet.

This method is not quite as convenient as on other platforms, but it’s your only choice if you’re not prepared to root your phone. It’s good enough for stuff like these email instructions, anyway.

Categories: Guides Tags: , ,

My 35mm pinhole camera

December 1st, 2009 Jonathan 2 comments

After I posted the other day about building a pinhole camera, I immediately ordered a body cap from eBay. Last night it arrived, and here’s how I made my pinhole camera.

Making the pinhole “lens”

Not only do pinholes have to be tiny in diameter, they should also be made through a thin material. I didn’t even attempt to make a pinhole directly in the body cap. I drilled a 10mm hole and superglued a piece of tin foil over the hole. Using a fine pin, I made a small hole.

Front of pinhole lens

Front of pinhole lens

Rear of pinhole lens

Rear of pinhole lens

Uh, that’s it. Most guides I write have more steps than this, but making a pinhole “lens” for an SLR really is this easy.

What’s the f-number?

The formula for working out the f-number is pretty simple:

           focal length
f-stop = -----------------
         aperture diameter

The aperture diameter is the diameter of the pinhole, and the focal length is the distance between the film and the pinhole.

The Canon AE-1 Program has a small mark on the side to indicate the position of the film plane. The rough distance between this mark and the pinhole is 36mm. Getting a decent estimate of the pinhole is a little trickier, as I need to measure the diameter of the pinhole. The best I could come up with was to take a picture of the pinhole next to a ruler with my Fuji S9600 and a macro lens.

The pinhole

The pinhole

I reckon that’s approximately 0.2mm across.

          36
f-stop = ----- = 180
          0.2

So this is a pretty tiny aperture, and we are going to need long exposures to get it to make a decent picture on film.

Earlier on I pointed the camera out of my window. With the shutter set to its slowest value of 2 seconds, the meter reckoned it wanted an aperture of 8. 180 is 22 times greater than 8, so I need to make my shutter 22 times longer than 2. So we are talking 40-odd seconds for outdoor landscape photography in daylight on ISO200 film. In lower light conditions and perhaps on ISO125 film (such as my Ilford FP4) it’s easy to see that I might need to expose for 2 or 3 minutes.

Although 2 seconds is the longest my SLR can do automatically, it has a mode where the photographer can hold the shutter release for as long as necessary. Never thought I’d need a stopwatch for my photography! :)

My 35mm pinhole camera

My 35mm pinhole camera

The advantage of making a removable pinhole lens is that I can carry it around and easily change between lenses.

Keep an eye on my photo blog. When I’ve got this film developed I’ll scan and post the pinhole images there.

Update: I have now uploaded some of the pinhole photos.

Calibrating a TFT monitor

October 26th, 2009 Jonathan No comments

I hadn’t realised how important it is to calibrate a monitor correctly.

My former method of “calibration” was simply to set the monitor’s contrast to maximum, and set the monitor’s brightness to a value that looked comfortable to me. I didn’t bother changing any settings in software.

But I got caught out.

Last night I took some photos and tweaked them on my PC so they looked OK. I published them and thought nothing of it. But several of my friends commented that they looked a bit dark, and when I checked the pictures out on two of the computers at work, they were indeed too dark.

My badly-calibrated monitors at home caused me to wrongly edit an image. So I read up on how to calibrate a monitor. There are many ways, but the method I’m writing about here is nice and simple.

  • If you have TFTs, they are sensitive to the angle you look at them. Tilt them so they face directly at you.
  • Turn the lights off in the room you are working in.
  • On the monitor, set the colour temperature to 6500K
  • On the monitor, set the contrast to 100%
  • Look at the gamma black chart below. Adjust the brightness on the monitor until:
    • Bar A is just visible at the bottom
    • Bar B is visible from the bottom to about halfway up the chart
  • Gamma black chart

    Gamma black chart

  • Absolute black on your monitor is now calibrated.
  • Find how to adjust the gamma on your computer. For example, I am running the proprietary nVidia X driver on Fedora and it comes with a convenient control panel. You can use Adobe Photo Shop to adjust the gamma, or xgamma under X Windows on Unix/Linux systems.
  • Now look at the gamma chart below. Sit as far as possible from the monitor and squint so the lines blur together.
  • Gamma chart

    Gamma chart

  • Adjust the gamma on your computer so the shade of grey completely across the gamma column is the same at 2.2.
  • The monitor is now calibrated.

References

Categories: Guides, Photography Tags: , , ,