Firewalls, IPTables, and Bears, Oh My!

I will be playing with iptables over the next couple of weeks in order to more easily change my rule sets to block by IP address, request type, location (if possible), load balance, etc., so if you experience any downtime, I apologize in advance. I will post more information when I am done with the changes.

Bookmark and Share

Chumby Remote – Part 1

Part 1 of my “Chumby Remote” series will cover the Chumby classic proc entry for emulating touchscreen clicks and bend sensor presses.

Overview

If you’re unfamiliar with the Chumby, you should go to their website and check them out. They’re a ‘cute’ little Internet device that is meant to be an always-on appliance to “keep you connected” to your digital life. I have one on my night stand that is no more than a glorified alarm clock that I’ve had it since April of 2008 and justified the cost by saying it would be a new hobby since I love working with embedded systems devices. The enjoyment is even better since the Chumby is completely* “open” and there’s a very helpful community. Unfortunately life got in the way of the new potential “hobby” and it took until “paternity leave” for my second child for me to have any amount of free time to dedicate to hacking my Chumby. When the Chumby One was announced, I promptly ordered one since certain aspects were even easier for hacking (microSD rootfs, r/w filesystem, easier to “hack” case for adding a serial console).

The Idea

This project started because I wanted to be able to remotely start/stop Pandora radio as well as disable alarms if I woke up prior and didn’t want to wake up my wife. Chumby provides event interfaces for starting/stopping certain music sources, but Pandora isn’t one of them. ChumbyLurker has also written a nifty perl cgi script that will allow remote editing of alarms (which had a couple bugs) that wasn’t around when I came up with my idea. I have enough web experience as well as linux experience to get this working rather quickly, so off I went.

Getting to work

Step 1 – See how the touchscreen device is getting information to the Chumby flash player. With a quick look to the loaded modules, it was obvious the module “chumby_tsc2100″ was the touchscreen driver.

Step 2 – Obtaining the source was as easy as going to http://files.chumby.com/ which has the complete source for (almost) everything on the Chumby platform as it is (almost) all GPLv2 software. I imported all of the Chumby kernels available into a git repository for easy tracking of differences between firmware revisions as released by Chumby Industries.

Step 3 – Modify the source. I chose /proc entries as my “entry point” for emulating touches because I’m familiar with them so it would be a quick and easy way to get things working. With only a few lines of code in an hour or so, I was able to get emulated touch screen presses working by echoing coordinates to the new proc entry. Similarly I added an entry for the “bend” sensor on the top of the chumby.

$ echo "300 300" > /proc/chumby/touchscreen/coordinates
$ dmesg | tail -n 1
[2001256.670000] pen down - set coordinates x=1, y=1
$ echo "0 0" > /proc/chumby/touchscreen/coordinates
$ dmesg | tail -n 1
[2001261.680000] pen up
$ echo 1 > /proc/sense1
$ dmesg | tail -n 1
[2001395.680000] bent
$ echo 0 > /proc/sense1
$ dmesg | tail -n 1
[2001401.220000] not bent

If you’re a git user, you should be able to branch from 2.6.16, throw on the chumby kernel, then use git am to apply these patches:

*Note: The control panel is not open source, although through the Chumby forums Chumby Industries respond to a lot of input from the community.

Bookmark and Share

SheevaPlug Migration

Recently my wife and I had our second child. Instead of putting the kids in day care and pay somebody else to raise our children we decided that my wife would stay home. This meant a drastic change to our income. As part of our cost cutting measures, I decided to leave my VPS hosting provider which is heavily overkill for the small traffic our websites generate. I never once had a problem with Linode and highly recommend them to anybody looking for quality service at a good price. Their staff is so educated with linux they make my skills seem non-existent.SheevaPlug

Over the last couple of years I have moved away from running machines at home 24/7. This used to be the norm for me so I would have constant access to my data, however it became a nuisance for a few reasons. First, it meant always having a machine on generating heat and sucking power. Second, the longer the machine was up, the more “hours” on things like hard drives and CPUs. This makes hard drives die much faster. The downfall with rebooting often is PSUs are more likely to fail. All in all, I was happy with my solution for a couple of years. SSH to my router (which is running OpenWrt) and use wake-on-lan packets to turn on machines if I wanted at my data. Then I could also remotely shut down my machines to save power when I was done getting what I needed.

I didn’t exactly like the time I had to wait for things, and my wife couldn’t then access data without doing “magic” which she didn’t like. This made it hard for me (an anal-retentive data hoarder) to have a way to “share” the family pictures, and other important things since the machines were only on when I wanted them on. I began looking for a solution and came across the SheevaPlug. It is an embedded system that ships with an ubuntu installation by default and it’s only $100. I had to get one! It runs a 1.2GHz Kirkwood ARM processor and has 512Mb RAM and 512 Nand flash.

The little thing draws just about 5 watts according to my kill-a-watt with a 500 Gb Seagate drive as the root filesystem. I have migrated all my services from Linode to my SheevaPlug to run everything from home using my business Internet connection. The SheevaPlug has plenty of horsepower to run all of my services which include apache (with php5), samba, nfs, email (postfix, postgrey, courier-authlib, courier-imap, courier-pop, spamassassin, clamav, amavis, roundcube). Quite impressive if you ask me. It’s been really stable even though it’s labeled as a “development kit” and my uptime and load average can be seen in the footer of this website.

Bookmark and Share

AddThis WordPress Plugin with WPMU

UPDATE 2/9/2010: AddThis recently released a version 1.6.1 which fixes the issues. It contains *basically* this patch with if ( wordpress version > 2.7 ) checks to maintain backward compatibility. I wasn’t worried about that because people shouldn’t run old, unsecure versions of wordpress, however I can see why AddThis wouldn’t care and would want their plugin to work across the board.

Recently, I wanted to add the AddThis WordPress Plugin and I couldn’t get it to work with WPMU. I found a thread on the addthis forums that discussed the exact problem, with a suggestion like the openid problem that had been updated.

The post/bug report on openid suggested to update the plugin to use the new register_setting/settings_fields methods which are now available with WordPress 2.7 and above. The documentation for that is here: http://codex.wordpress.org/Creating_Options_Pages.

I made the same changes, and everything seems to work. Here is a patch:

addthis_wpmu_fix.patch

diff --git a/addthis_social_widget.php b/addthis_social_widget.php
index 39c4a5c..3ed2c5c 100644
--- a/addthis_social_widget.php
+++ b/addthis_social_widget.php
@@ -51,6 +51,26 @@ $addthis_styles = array(
                         , 'custom' => array('img'=>'http://example.com/button.gif', 'w'=>16, 'h'=>16) */
                     );

+if ( is_admin() ) {
+    add_action( 'admin_init', 'register_addthis_settings' );
+}
+
+function register_addthis_settings() {
+    register_setting('addthis', 'addthis_username');
+    register_setting('addthis', 'addthis_style');
+    register_setting('addthis', 'addthis_sidebar_only');
+    register_setting('addthis', 'addthis_isdropdown');
+    register_setting('addthis', 'addthis_showonpages');
+    register_setting('addthis', 'addthis_showoncats');
+    register_setting('addthis', 'addthis_showonhome');
+    register_setting('addthis', 'addthis_showonarchives');
+    register_setting('addthis', 'addthis_language');
+    register_setting('addthis', 'addthis_brand');
+    register_setting('addthis', 'addthis_options');
+    register_setting('addthis', 'addthis_header_background');
+    register_setting('addthis', 'addthis_header_color');
+}
+

 /**
 * Adds WP filter so we can append the AddThis button to post content.
@@ -216,7 +236,7 @@ function addthis_plugin_options_php4() {
     

AddThis

- +

Required

@@ -305,9 +325,6 @@ function addthis_plugin_options_php4() {
- - -

Bookmark and Share

Mirror Checking using a “live” md5sum

If you’ve “mirrored” some files and want to do an md5sum check recursively without an intermediate file (md5sum > file; md5sum -c file) you can do it in one easy step using this from the relative path where you are mirroring:


ssh ${HOST} find ${DIR} -type f -exec md5sum {} \\\; | sed sF${DIR}FF | md5sum -c -

This will ssh to the machine, run the md5sum, pipe it to sed to remove the absolute path prefix to make the md5sum ‘file’ (stdin to the final md5sum) use relative paths.

Bookmark and Share