Category Archives: Workedforme

HowTo: Load Mail Archives into GMail with Correct Dates

Another quick Google service related HowTo, as I just spent several days working on the task of uploading all my old mail into my Gmail account.

The Problem: Load your old mail archives into GMail, and keep the correct dates!

So say you’ve used various mail programs over the years, or change computers a lot, or for whatever reason have a large body of email sitting on your machine that you would like to upload to GMail. After doing a bit of webcrawling, you may have come across solutions such as the GMail Loader. However, I found that getting GMail Loader to work was painful, and even when it did, uploading my email turned into a huge mess, where all the emails seemed to have been sent on the day I did the uploading. They were all there, and searchable, but very annoying. There must be something better.

The Solution: Copy mail using Thunderbird and IMAP

Fixing this problem is actually really easy. Using GMail’s relatively new IMAP feature and the Thunderbird mail client (others likely work as well, I have not tested), it’s a a few easy clicks. Basically, just copy all your old email up there, and viola!

  1. To start, you need to get your mail archives accessible in Thunderbird. There’s lots of information out there about converting mailbox types and importing from one program to another; I will assume you have gotten that far.
  2. Enable IMAP access on your GMail account, by logging into GMail, clicking on Settings in the upper right corner, changing to the “Forwarding and POP/IMAP” tab, and clicking on “Enable IMAP” near the bottom.
  3. While you’re here, check out the “Configuration Instructions” link, to get a leg up on the next step.
  4. Now, add your GMail IMAP account to Thunderbird, using the Tools->Account Settings…->Add Account wizard. Note: in this wizard, add your GMail account as an Email Account, NOT as a GMail account, because we need to specify the IMAP settings, rather than use Thunderbird’s default POP access.

    The IMAP settings you need may differ depending on your account, but mine are:

    Server Type:
    IMAP Mail Server
    Server Name:
    imap.google.com
    User Name:
    full_email_address@gmail.com (or full_email_address@hosted_domain.com)
    Use Secure connection:
    SSL (Note: this changes the port to 993, which is correct.)
  5. Now, click on the Inbox folder of your GMail account in Thunderbird to make sure your connection is working. This will likely prompt you for your password as well, and will load the full list of folders on your GMail account. Note that GMail presents a folder for each Label you define in the web interface.
  6. To copy email to GMail, all that is left is to select the original messages in Thunderbird, right-click, and pick “Copy To”. Under the menu, choose your GMail account, and then which folder (think: label) you want to copy to.

    For instance, to drop all the email in your Inbox, use the Inbox. If you’d rather label everything and bypass the Inbox, pick a different folder. For me, I created a label (you can do this by creating a folder in Thunderbird) for the email address I was moving mail from (blah@oldaddress.com). Then I did “Copy To -> me@gmail.com -> blah@oldaddress.com”.

    For Sent Mail you can get these to show up in your Sent folder on GMail by copying them to the special [Gmail]->Sent Mail folder. Another useful special folder is the [Gmail]->All Mail folder, where you can copy messages that you do not want in your Inbox, but also do not necessarily want any other tag on.

  7. Give Thunderbird some time to process (you’ll see progress messages in the status bar), and you’re done!

Correct Way to set up OpenVPN Client on Mac OS X

The Problem

You want to run an OpenVPN Client on Mac OS X. Your OpenVPN server will be serving DHCP, as well as pushing down DNS server addresses. You’ve tried connecting, and it just doesn’t seem to work. Perhaps you even see a large number of errors of the type:

write to TUN/TAP : Input/output error (code=5)

The Solution

When you connect via OpenVPN, it is the responsibility of the client to process pushed dhcp-options (including the DNS server rules), and do something useful with them. On a linux system, you could, for example, incorporate these into /etc/resolv.conf. Consult your distro’s openvpn documentation for more information.

However, this does not work on a Mac, because Mac software (even down to ssh and ping) doesn’t use /etc/resolv.conf under OS X 10.4… Oops. The solution? A combination of two tools: ipconfig and scutil. These together can manage 10.4’s new DNS configuration system, and set the tap device to obtain an address via DHCP. The problem is discussed further on nicholas riley’s blog, though his solution, a python script, a) is complicated to install, and b) did not actually work for me once installed, though I didn’t dig deep enough to understand why.

The best solution is to run an “up” script as part of the OpenVPN connection process, which will handle the necessary configuration for you. The script is provided on the Openvpn-users mailing list, by Ben Low.

Here’s how to use it with the excellent OpenVPN client Tunnelblick:

  1. Install Tunnelblick, and create your OpenVPN config. I’ll assume that you know how to do this, or you wouldn’t be here. If not, consult the documentation for OpenVPN.
  2. Download this script (copied from the openvpn-users mailing list). Save it to ~/Library/openvpn, the folder where your Tunnelblick OpenVPN configuration lives.

    OpenVPN TAP up-down Script: tap-up-down.sh

  3. Now, make the script executable, by running:

    chmod +x ~/Library/openvpn/tap-up-down.sh

  4. Edit your configuration file to include these lines:

    up ./tap-up-down.sh
    down ./tap-up-down.sh

  5. Changing your configuration file will have disconnected Tunnelblick if it was connected. Tunnelblick will also prompt you again for your administrator password, since security-sensitive files have been modified.
  6. Time to test! Open a Terminal window, and run the command:

    scutil –dns

    to see the current configuration of DNS resolvers. Then connect to your VPN in Tunnelblick, and run the command again:

    scutil –dns

    If all goes as planned, you will see your VPN DNS resolver properly included in the configuration. Congratulations!

  7. You should now be able to ping internal hosts by their internal DNS names, e.g.:

    ping internal-server

Good luck!

Updated 11/30/2007 to add chmod +x. Thanks Karel!

Totally Seamless SSHFS under Linux using Fuse and Autofs

This is awesome.

I worked on this for something like 2 hours this afternoon, and finally tracked down all the nuances to get it working. I’m really pleased with the results, and hope that they can be of some to use to you as well, because I could not find a decent tutorial on this subject despite extensive Googling.

The Problem: Connect to a remote filesystem over SSH

Odds are if you’ve stumbled on this tutorial, you already know the problem: You want to access a remote file system over SSH. You want to use FUSE SSHFS, and you don’t want to ever have to think about it, so you’re looking for Autofs integration. To keep this to the point, I’m going to skip over the installation of these packages and just explain the configuration, especially since installation is very distribution specific. I’ll simply say on my system (Ubuntu Feisty) it consisted of:

sudo apt-get install sshfs autofs

The Solution

Getting SSHFS to work with Autofs really isn’t hard, you just need the magic configuration. Here’s how I got things working for me:

  1. Set up certificate authentication for your local root to the remote account on the remote machine, by use of sudo ssh-keygen locally, and the (remote account’s) ~/.ssh/authorized_keys file.
  2. Test the certificate authentication by verifying that the following command does not prompt for your remote password:
    sudo ssh remoteuser@remotehost uptime
  3. Test that sshfs can establish the requisite connection:
    sudo mkdir /mnt/sshfs_temp
    sudo sshfs remoteuser@remotehost: /mnt/sshfs_temp
    sudo fusermount -u /mnt/sshfs_temp
    sudo rmdir /mnt/sshfs_temp

    Note that the : is required after the host to specify the remote directory. (: alone means the remote user’s home. :/remote/path indicates a remote path.)

  4. Add the following line to your /etc/auto.master file:
    /mnt/ssh /etc/auto.sshfs        uid=1000,gid=1000,--timeout=30,--ghost

    Where /mnt/ssh is the path you want all ssh automounts to appear in,
    1000 is the UID of the user you want the sshfs mount to belong to (i.e., be writable by),
    1000 is the GID of the user you want the sshfs mount to belong to, and
    30 is the timeout in seconds to keep the FUSE connection alive.

  5. Copy the following into a new file /etc/auto.sshfs:
    #
    # This is an automounter map and it has the following format
    # key [ -mount-options-separated-by-comma ] location
    # Details may be found in the autofs(5) manpage
    remote1     -fstype=fuse,rw,nodev,nonempty,noatime,allow_other,max_read=65536 :sshfs#remoteuser@remotehost1:
    remote2  -fstype=fuse,rw,nodev,nonempty,noatime,allow_other,max_read=65536 :sshfs#remoteuser2@remotehost2:/remote/path
    

    This creates two sshfs mappings (obviously, adding or removing lines creates more or fewer mappings).
    The first will be at /mnt/ssh/remote1, and map to the home directory of remoteuser on the host remotehost1.
    The second will be at /mnt/ssh/remote2, and map to the directory /remote/path on the host remotehost2, with the permissions of the user remoteuser2.
    Note the characters to escape # and : These escape characters are what took me two hours to track down: FUSE requires a parameter of the form: sshfs#user@host:directory, but autofs treats everything following a # as a comment, and the : character has a special meaning. These characters must be escaped by a

  6. Restart autofs to reload the configuration files:
    sudo /etc/init.d/autofs restart
  7. Test it out! As root or the user indicated by uid above, run:
    ls /mnt/ssh/remote1

    You should be greeted by the contents of the remote file system. Congratulations!

The Problems

  • This exact setup only works for one user due to specifying a uid. This is fine for a home desktop system, but will likely need further work to allow multiple users access to the remote filesystem. Perhaps careful usage of gid could alleviate this problem, though logging into the remote machine as a specific user still represents a security risk.
  • I have not examined the architecture enough since I am only seeking to enable my home desktop system, so I cannot vouch for the security of this setup whatsoever. For example, the use of the allow_other option for FUSE may have security consequences since the mountpoint is created as root (to my understanding, at least).

Howto: Resize Your Own Watch

I haven’t put too many posts up here that are actually helpful to anyone else in any way, so I thought I should start working on that. This may or may not be helpful to anyone either, but what the heck, I already had the pictures…

Disclaimer: I am not a jewelry / watch expert, and in fact know next to nothing about them. What I present here worked for me, but I make no claim that it will work for you and take no responsibility for your actions and any damage they may cause. 🙂

Back-Story

So why am I resizing a watch band, of all things? Well, my parents bought me a Seiko watch for Christmas during my senior year of high school, which I like very much. Unfortunately, wearing it for several years (and drumming with it on) popped one of the hands off one of the smaller dials, and that hand now rattles around freely under the crystal, frequently getting stuck under other dials and jamming the watch up:

Note the alarm dial (bottom) of the old watch is missing a minute hand, which is located upside down jamming its second hand (left dial).

After sending it off to Seiko for a repair estimate ($162), we decided it wasn’t worth the money to repair, as it would be better spent toward the purchase of a new watch. Fast-forward several months, and I find my very same watch on Amazon.com for $105 (no longer available). I was pretty excited to have a chance to get it fixed, so I bought it. Fast-forward another week or so, and my new watch arrives. Three sizes too large for my wrist. Oops.

And so, here we are.

Goals

  • Resize a watch band of the “pin-and-link” type seen above.
  • Avoid fees to have it resized at the mall
  • Avoid damage by the inept worker at the Younkers jewelry department

Tools

  • Pentel 0.5mm mechanical pencil tips
  • Thumbtacks
  • 1″ Brad
  • Light hammer

Steps

  1. First, take a close look at your watch and determine how many links need to be removed, and from which sides of the clasp. Keep in mind that you should try to balance the removed links from both sides, or the clasp will end up on the edge of your wrist instead of the back.
    I had this step easy, as the old watch was fitted correctly to my wrist already as a model. In my case, I needed to remove 3 links total: 2 from one side of the clasp and 1 from the other.
  2. The next step is to determine exactly which links you will need to remove to accomplish this, and which pins hold them in place. Generally, you will need to remove 2 pins (one from each end of the link(s) you will remove), and then replace 1 to rejoin the watch band.
  3. Removing and inserting these pins without a commercial tool for doing so is the tricky part, and why I am writing this Howto. So, on to the pins:
  4. On my Seiko, I started by removing one of the pins on the links near the clasp, in the direction indicated by the small engraved arrow:
  5. One method to remove these pins uses the tip from a 0.5mm mechanical pencil. Remove the tip and place it point up on a solid surface. Then press the watch down, aligning the pin with the pencil tip’s metal shroud. Apply force as vertically and firmly as possible.
    This was the first method I tried, and though it worked for two of the pins I needed to remove, it destroyed 3 mechanical pencils by pushing the metal shroud into the tip. For this reason, I do not recommend this method.
  6. A second method is to use a thumbtack. Place the tack point-upward on a sold surface. Very carefully align the watch pin on the tip of the tack and press downward firmly. It is very important to keep the watch aligned so that you are always pushing directly into the pin, not at any angle. If you are not careful, the watch will slip off the pin, and if you’re like me, you’ll stab the pin a full quarter inch into the tip of your finger.
    Despite the increased danger in this method, I found it to be the most effective, and though I did destroy another few tacks in the process, I was able to remove the remainder of my pins relatively easily.
  7. Once all the pins are removed, you simply rejoin the remaining watch band pieces by reinserting pins as necessary. This is the second significant challenge.
  8. When reinserting the pins, it worked best for me to insert them in the opposite direction I had removed them in. I attempted to insert the pin in the direction of the arrow the first time around, pushing the “bulge” in the pin through first, with the result of destroying the pin:
  9. It is possible to push the pin nearly all the way back in just by hand and pressing the watch against a table, but replacing the pin the last 1/16″ proved trickier. You would like to reposition the pin as it originally was, to minimize the risk that it will fall out.
  10. The best method I found for recessing the pin back to its original position was to tap it lightly with a hammer, via a nail. Place the watch on a solid board or edge of a table so that the edge of the watchband rests solidly on the surface. Then align a small brad (I used a 1″) with the stub of the pin sticking out, and rap it lightly with a hammer as shown:
  11. Repeat for all pins that you need to remove and replace to adjust the watch size.
  12. And that’s it!

    Finished watch, down to size with minimal scratches.


    Total bill of materials:

    • 3 mechanical pencil tips
    • several thumbtacks
    • one watch pin
    • one stabbed finger