nick.recoil.org

AppleTV & Ubuntu hacking (0)

I’ve finally enabled SSH on my long dormant AppleTV, and am integrating it into my DVB / Rails / Beanstalk / MySQL system for processing data. I’ve used the Patchstick image available from atv4windows. I ended up unpacking and dd’ing the image from the Mac, but the process remains exactly the same. I now have Perian, ssh and a slew of other things enabled, and all I need now is to attempt the hack to get composite output working. I’ve yet to take the plunge and replace my old CRT with an LCD TV.

Incidentally, for anyone looking to figure out the ssh username and password for your freshly enabled ssh daemon, they are both frontrow, and that user has passwordless sudo privileges.

I also had a minor breakthrough with my x86_64 Ubuntu 8.04 machine. I have a Zyxel G-202 Wireless USB stick, to keep the number of trailing wires to a minimum, but I kept getting an error saying:

1
zd1211rw error ioread32(CF_REG1): -110

Which was exceedingly unhelpful. I eventually tried disabling hi-speed USB from the BIOS, and rebooted to find it sprang into life immediately. Great! What was even more strange that when I rebooted and reset the BIOS back to enable USB 2.0, the G-202 kept working. I’m unsure whether this is due to the device not being cold booted, and I’ve yet to see if it stops working after I power the system off, but so far so good, and I don’t need to resort to NDIS.

Mongrel init.d script (0)

I’ve slightly modified Bojan Mihelac’s Mongrel init.d script to cope with the situation where there are stale PID files left from a server failure.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60

#!/bin/env ruby
#
# mongrel Startup script for Mongrel by Tim Morgan, modified by bmihelac and Nick Ludlam
# Originally from http://source.mihelac.org/2007/3/27/customized-mongrel-startup-script
#
# chkconfig: 2345 85 15
# description: mongrel manages Mongrel
#

apps = [
  {:app => 'app1'},
  {:app => 'app2'},
  {:app => 'app3'}
]

default_port = 8000
default_options = {
  :app_dir => '/var/www',  :environment => 'production'
}

pid_location = "log/mongrel.pid"

if ['stop', 'restart'].include? ARGV.first
  apps.each do |app|
    options = default_options.merge(app)
    path = File.join options[:app_dir], options[:app], "current"
    puts "Stopping #{path}..."
    `/usr/local/bin/mongrel_rails stop -c #{path} -P #{pid_location}`
  end
end

if ['start', 'restart'].include? ARGV.first
  apps.each do |app|
    options = default_options.merge(app)
    path = File.join options[:app_dir], options[:app], "current"
    port = options[:port] || default_port
    pid_file = File.join path, pid_location

    # Check and remove stale PID file. Platform needs "ps -p" support
    if File.exists?(pid_file)
      old_pid = File.read(pid_file)
      `ps -p #{old_pid}`
      if old_pid.to_i > 0 && $?.exitstatus == 1
        puts "Removing stale PID file"
        File.unlink(pid_file)
      end
    end

    puts "Starting #{options[:app]} on #{port}..."
    `/usr/local/bin/mongrel_rails start -d -p #{port} -e #{options[:environment]} -c #{path} -P log/mongrel.pid`
    default_port = port + 1

  end
end

unless ['start', 'stop', 'restart'].include? ARGV.first
    puts "Usage: mongrel {start|stop|restart}"
    exit
end

MacPorts contributions

I’ve been accepted as a committer to MacPorts, initially to look after beanstalkd, but I’ll hopefully extend what I contribute to. I’ve been a consumer of Macports (née Darwinports) for a long while, and use it regularly to create my local development environment on the Mac. As of today, I have 98 ports installed, from ImageMagick to zlib, and I’m happy to be giving back some effort to something I get so much value from.

Saving my blown Seagate Barracuda 7200.10 hard drive

Whilst messing around with my Mini ITX box, I managed to touch the power connector onto the drive backwards, blowing one of the components near the connector. I noticed that the controller board is screwed on with standard torx screws, so I took them out, curious about the connector to the main chassis.

After removing them, the board came away easily, and uses pressure pads as a connection mechanism, rather than ribbon cable or other methods. This set me wondering about whether this would be a replaceable part. I contacted Seagate, who told me that they don’t supply them separately. I then wondered about getting an identical drive, and replacing the old board with one from the new drive, so I went ahead and ordered a replacement; I’d need it anyway, even if this attempt at data recovery failed.

After it arrived, and I’d done the swap, I turned on the machine, and back came my drive with all my data on it, safe and sound. I did worry about whether the IDE controller boards carry some kind of mapping table that’s specific to a particular set of platters, but this isn’t the case, it seems. Unfortunately I’ve no way of repairing the original blown board. Replacing surface mount components is tricky.

For anybody wondering, you can replace the controller board for a Seagate Barracuda 7200.10 500GB drive with no ill effects.

Stalling Wi-fi uploads on Mac OS X 10.5.2

I was sitting in my local wifi-enabled cafe in London for the first time yesterday, and was struck with a peculiar problem. I could attach to their Wi-fi network properly, and browsing webpages worked fine, but trying to scp a small file to one of the recoil.org servers was stalling at exactly 2064kB.

I had a quick glance around for the problem on Google, and a thread turned up on the Apple message board. These people were discussing the same symptoms as I was having; An scp would start out fine, but stall after a particular amount of data had transfered. Following lots of discussion about tuning net.inet.tcp.delayed_ack, I tried fiddling with all sort of sysctl and ifconfig settings for the best part of an hour, and eventually had success.

I had to drop the MTU of en1 down from 1500 all the way down to 1400 for the problems to go away. The more common settings you might find via Google such as 1492 didn’t resolve the issue. For those of you who might have arrived here looking at similar issues, type the following into a Terminal window:


 sudo ifconfig en1 mtu 1400

I’m not entirely sure what was going on, but Path MTU discovery is turned on by default on the Mac. By blocking ICMP packets on the Wifi network, it may cause issues with the discovery system. If people are more familiar with the networking circumstances here, drop me a comment/email.

Search

Sections

About Nick

I am a freelance technology consultant and developer working in London, with a particular interest in web development and video media.

This site contains my thoughts about technology, the universe and everything. If you would like to get in contact, have a look at the About me page.