Dynamic Rackspace DNS updater script

I’ve been maintaining my own DNS servers for a long time. In an effort to streamline my life, I’ve decided to move my DNS to Rackspace. I have a record for my home IP that I’ve updated manually for a couple of years. While I could have written a script to do this with BIND, I just never got around to it. Part of the reason I decided to move my DNS to Rackspace so I didn’t have to maintain another server (I have enough at work to worry about) and they have an API for managing your zones.

To make updating my home DNS more streamlined, I wrote a quick script last night to handle updating the DNS record I keep for my home IP, which is dynamic. You can find it here on Github.

While I included a small Flask app to be hosted on a remote system to give you your local public IP, you’re free to use mine. For IPv4 addresses, use http://ipv4.dndy.me/, and for IPv6, http://ipv6.dndy.me/. The updater script is smart enough to determine whether an A or AAAA record should be updated based on what it gets back from the IP service.

Chromium easy update

Update: The URL’s no longer work, so this is busted. I’ve gone back to Firefox since 4.0 came out. It is heavier than Chrom(e|ium), but I was finding that there were some features I was really missing. As such, this still can serve as the basis for an update if given the correct URL’s.

I’m a bleeding edge kind of guy. No, I’m not. When it comes to software, I’m generally a bleeding edge kind of guy. I really like Chromium. I hate going to the Chromium build site, downloading it, closing my browser, then moving it in place. I’m a lazy admin.

Here’s a couple quick-n-dirty bash script that retrieves the latest Chromium build.

Mac Version

Special Notes:

  • Ensure Chromium is not running when you run this or it will not work out as planned (open files)
  • Assumes that Chromium is installed in /Applications, not /Users/user/Applications

  • #!/bin/bash
    echo -n "Retrieving latest build: "
    VER=$( curl -s http://build.chromium.org/f/chromium/snapshots/chromium-rel-mac/LATEST )
    echo "$VER"  
     
    TMPDIR=$( mktemp -d /tmp/chromium.XXXXX )  
     
    echo "Downloading Chromium: "
    curl -o ${TMPDIR}/chromium.zip http://build.chromium.org/f/chromium/snapshots/chromium-rel-mac/${VER}/chrome-mac.zip  
     
    echo -n "Decompressing archive: "  
    unzip -qqx ${TMPDIR}/chromium -d ${TMPDIR}  
    echo "done"  
     
    rm -rf /Applications/Chromium.app  
    mv ${TMPDIR}/chrome-mac/Chromium.app /Applications/  
     
    rm -rf ${TMPDIR}  
    echo "New Chromium installed!"

    Linux Version

    Special Notes:

  • Requires 7zip to be installed
  • Assumes that Chromium is installed in /opt
  • I have a group named “opt”, to which my user belongs, that has write access to /opt
  • I have /opt/bin, which is in my $PATH, that has a symlink for “chrome” pointed to /opt/chrome-linux/chrome

  • #!/bin/bash
    echo -n "Retrieving latest build: "
    VER=$( curl -s http://build.chromium.org/f/chromium/snapshots/chromium-rel-linux-64/LATEST )
    echo "$VER"  
     
    TMPDIR=$( mktemp -d /tmp/chromium.XXXXX )  
     
    echo "Downloading Chromium: "
    curl -o ${TMPDIR}/chrome-linux.zip http://build.chromium.org/f/chromium/snapshots/chromium-rel-linux-64/${VER}/chrome-linux.zip  
     
    echo -n "Decompressing archive: "  
    7z x -tzip -o${TMPDIR} ${TMPDIR}/chrome-linux.zip > /dev/null
    echo "done"  
     
    if [ -d /opt/chrome-linux.1 ]
    then
            rm -rf /opt/chrome-linux.1
    fi
     
    if [ -d /opt/chrome-linux ]
    then
            mv /opt/chrome-linux /opt/chrome-linux.1 
    fi
     
    mv ${TMPDIR}/chrome-linux /opt/ 
    find /opt/chrome-linux -type d -exec chmod 2775 {} \;
    find /opt/chrome-linux -type f -perm /100 -exec chmod 775 {} \;
    find /opt/chrome-linux -type f ! -perm /100 -exec chmod 664 {} \;
    chgrp -R opt /opt/chrome-linux
     
    rm -rf ${TMPDIR}  
    echo "New Chromium installed!"

    Enjoy!

    8 Nov 2010: Updated to match new URLs being used

    MacPorts “PortIndex file may be corrupt” Resolution

    In the past few months, I moved to a Mac, which has been great. Shortly after switching, I found MacPorts, which has also been great. The other day, however, when doing an upgrade, I got the following warning over and over and my upgrade wouldn’t complete:

    Warning: It looks like your PortIndex file for rsync://rsync.macports.org/release/ports/ may be corrupt.

    I couldn’t find a clear answer on what was going on, until I found a bug report on the MacPorts site. The fix for this will be put into MacPorts 1.9.0, but I’m on 1.8.2 now, so that doesn’t help much.

    The issue sounds like it has to do with a cache of the PortIndex can build up stale information. My brute force resolution was to remove that cache. I wasn’t terribly sure where that was, but I did find it.

    $ locate PortIndex.quick
    /opt/local/var/macports/sources/rsync.macports.org/release/ports/PortIndex.quick
    $ sudo rm /opt/local/var/macports/sources/rsync.macports.org/release/ports/PortIndex.quick

    Alternatively, you could move the file out of the way if that makes you more comfortable.

    Once that was done, I went ahead and gave it try.

    $ sudo port sync
    Warning: No quick index file found, attempting to generate one for source: rsync://rsync.macports.org/release/ports/
    $ sudo port upgrade outdated
    ...

    All worked as it should! So until we see MacPorts 1.9.0, this will be my solution should I see this come up again.

    My address IS valid, Facebook!

    If you happened to have seen my previous post, Blocking spammers with Postfix alone, you saw that I use SpamCop for one of my RBLs. It’s worked great for years. My whole setup has worked great for over a year now with very minimal changes. Imagine my confusion when Facebook told me to that my email address was detected as no longer valid.

    Facebook Fail

    What?!

    So I dug in my mail server’s logs and found that SpamCop had listed some of the Facebook mail servers on their DNS Blacklist.

    Continue reading

    iPhone’s mail.app and IMAP folders

    IMAP Folders Example

    My IMAP Folders

    I use IMAP folders combined with fairly extensive Sieve rules to sort my incoming mail into the appropriate folders. This works great for me, because my Facebook notifications go to “Websites”, bill notifications go into “Bills”. It makes it easy for me to find what I’m looking for without having to sort through a single, massive Inbox.

    When I got my iPhone, I was very disappointed in its handling of folders. It simply lacks the ability to check all folders for new mail. I didn’t want to have to click through each folder to see if I got new mail in one of them. I wanted to be able to see my little mail badge with the number of new messages I had, when I got a new message, no matter what folder it happened to reside in. I thought of various solutions, such as writing a server-side IMAP proxy that would do the checking for me and present a virtual mailbox of only new messages. While it may have been a fun project, a friend pointed out a more obvious solution: setup a second mailbox and have all of my mail forwarded to it. Here are the details of what I setup.
    Continue reading