James Gardner


Revolution is coming… maybe!

Posted in Wild Speculation by thejimmyg on the June 21st, 2008

Yesterday I had a good discussion with people from the hub about the way I feel that something is going to change radically with the internet in the next 2-5 years. I think the source for this feeling is my belief that the internet is there, that in technical terms almost everything I ever wanted to create for the internet now exists.

This can only mean two things - technology will continue to become modularized enabling more and better-fitting solutions to problems to be achieved more cheaply or the way humans interact with technology will change so that the symbiosis of human and computer will become more efficient, not by technology better fitting the needs of humans but with humans better learning how to adapt to technology. In reality both are likely to happen but I think the major change will be in the realisation for the need for humans to adapt to the new world of technology which is a field which barely exists at the moment. IT will shift to be a small part about creating solutions with technology and a large part in changing human behaviour to better use the technological tools available. I want to be part of this revolution.

Python Odness

Posted in Python by thejimmyg on the June 16th, 2008

You probably already know that variables in Python are effectively passed by reference:

a = ['this', 'is', 'a', 'list']

def change(arg):
    arg.append('with')
    arg.append('new')
    arg.append('variables')
    print arg is a

change(a)
print ' '.join(a)

This program would result in the variable a being changed even though the appending of the extra words happens in the scope of the change() function. As you can see from the first print statement this is because the arg variable really is the same thing as the a variable, not a copy of it as would happen in C++.

The output from the program is:

True
this is a list with new variables

This behaviour is fairly understandable but I want to show you something you might not expect but which you really should be aware of. Consider this code, what would you expect to be printed the first time this function was called?

def test(a=[], b={}):
    print a, b
    a.append('a')
    b[len(a)] = 'b'

If you guessed [], {} then you would be correct. Try calling it again. What do you expect the second time?

The answer is might surprise you. It turns out to be [a], {1: ‘b’} because even though you are calling test() with no arguments, the previous call changed the values of the empty [] and {} to different values. The second time the function was called the definition was effectively:

def test(a=['a'], b={1: 'b'}):
    print a, b
    a.append('a')
    b[len(a)] = 'b'

As you keep calling test() the list and dictionary keep getting bigger. Now you might be suprised by this and wonder what would happen if you pass ordinary variables into the function. Well it appends a to the first one and adds a new key to the second one but this time because the variables aren’t the actual ones which make up the function definition the function definition isn’t changed. If you call test() again the variables from the function definition will go on incrementing. Here’s the full source:

def test(a=[], b={}):
    print a, b
    a.append('a')
    b[len(a)] = 'b'

test()
test()
test()
print
c = []
d = {}
test(c, d)
print 'Output: ',  c, d
test()

And the full output:

[] {}
['a'] {1: 'b'}
['a', 'a'] {1: 'b', 2: 'b'}

[] {}
Output:  ['a'] {1: 'b'}
['a', 'a', 'a'] {1: 'b', 2: 'b', 3: 'b'}

So, how do you avoid this problem?

  1. Never use mutable variables as defaults to functions.

Instead you can do something like this:

def test(a=None, b=None):
    if a is None:
        a = []
    if b is None:
        b = {}

This is very safe and always works.

  1. Make copies of the variables:

    def test(a=[], b={}):
        a = a[:]
        b = b.copy()
    

By creating local variables with the same names as the defaults you can no longer (easily) accidentally change the variables defined as defaults. The drawback is that you make copies of any arguments which are passed to the function which then uses up more memory.

  1. Be very careful not to actually change the values of the defaults.

This isn’t a particularly good idea because someone else looking at your code might not be aware of what you are doing and might change the value without realising.

I’d imagine quite a few libraries which allow mutable variables as default values might have this particular problem. In my own code I try to only use None as a default option. Do other people have any handy workarounds?

Empty Threading Example

Posted in Python by thejimmyg on the June 16th, 2008

I don’t have anywhere good to put this skeleton of threading code so it is going here!

from threading import Thread

class Thread1(Thread):
   def __init__ (self):
      Thread.__init__(self)

   def run(self):
      pass

class Thread2(Thread):
   def __init__ (self):
      Thread.__init__(self)

   def run(self):
       pass

t1 = Thread1()
t1.start()
t2 = Thread2()
t2.start()

# Both threads run at the same time until they finish or
# this code is called

t1.join()
t2.join()

MySQL on Ubuntu 8.04

Posted in Web by thejimmyg on the June 7th, 2008

I do this sort of MySQL administration a lot so I thought I’d document it this time. Much of the information is taken straight from the excellent MySQL 5.0 manual.

Installation

Get the latest MySQL:

sudo apt-get install mysql-server

Set a root password:

Package configuration

  ┌────────────────────┤ Configuring mysql-server-5.0 ├─────────────────────┐
  │ While not mandatory, it is highly recommended that you set a password   │
  │ for the MySQL administrative "root" user.                               │
  │                                                                         │
  │ If that field is left blank, the password will not be changed.          │
  │                                                                         │
  │ New password for the MySQL "root" user:                                 │
  │                                                                         │
  │ _______________________________________________________________________ │
  │                                                                         │
  │                                 <Ok>                                    │
  │                                                                         │
  └─────────────────────────────────────────────────────────────────────────┘

You have to repeat it:

┌──────┤ Configuring mysql-server-5.0 ├───────┐
│                                             │
│                                             │
│ Repeat password for the MySQL "root" user:  │
│                                             │
│ ___________________________________________ │
│                                             │
│                   <Ok>                      │
│                                             │
└─────────────────────────────────────────────┘

Once the install is finished MySQL will be running.

If you ever want to update the root password you can do it like this (you don’t need to be the UNIX root user):

mysqladmin -u root -p password 'new-password'

Enter the password you just entered during the installation when you see the Enter password: prompt.

Listening on All Interfaces

Remote access is disabled on Ubuntu by default. If you want MySQL to listen on all interfaces, not just localhost, edit /etc/mysql/my.cnf and comment out the line bind-address = 127.0.0.1:

sudo vim /etc/mysql/my.cnf

Then we restart MySQL:

sudo /etc/init.d/mysql restart

Now check that networking is enabled. Run:

netstat -tap | grep mysql

You should see a line like this one:

tcp        0      0 *:mysql                 *:*                     LISTEN     22565/mysqld

It looks like this if you only listen on localhost:

tcp        0      0 localhost:mysql         *:*                     LISTEN      9119/mysqld

The MySQL Command Prompt

You can now login to the mysql server with this:

mysql -u root -p

You’ll need to type in the password that you entered earlier:

root@james-laptop:~# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 16
Server version: 5.0.51a-3ubuntu5.1 (Ubuntu)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.


mysql>

You can exit by typing exit.

Existing Databases

MySQL sets up two databases by default:

mysql> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
+--------------------+
2 rows in set (0.00 sec)

mysql> use information_schema ;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> SHOW TABLES;
+---------------------------------------+
| Tables_in_information_schema          |
+---------------------------------------+
| CHARACTER_SETS                        |
| COLLATIONS                            |
| COLLATION_CHARACTER_SET_APPLICABILITY |
| COLUMNS                               |
| COLUMN_PRIVILEGES                     |
| KEY_COLUMN_USAGE                      |
| PROFILING                             |
| ROUTINES                              |
| SCHEMATA                              |
| SCHEMA_PRIVILEGES                     |
| STATISTICS                            |
| TABLES                                |
| TABLE_CONSTRAINTS                     |
| TABLE_PRIVILEGES                      |
| TRIGGERS                              |
| USER_PRIVILEGES                       |
| VIEWS                                 |
+---------------------------------------+
17 rows in set (0.00 sec)

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

mysql> SHOW TABLES;
+---------------------------+
| Tables_in_mysql           |
+---------------------------+
| columns_priv              |
| db                        |
| func                      |
| help_category             |
| help_keyword              |
| help_relation             |
| help_topic                |
| host                      |
| proc                      |
| procs_priv                |
| tables_priv               |
| time_zone                 |
| time_zone_leap_second     |
| time_zone_name            |
| time_zone_transition      |
| time_zone_transition_type |
| user                      |
+---------------------------+
17 rows in set (0.00 sec)

You shouldn’t modify these databases directly unless you are a MySQL expert and know precisely what you are doing. For testing various commands you are much better creating your own database.

Creating a Database

Create a database:

mysqladmin -h localhost -u root -p create first

This creates the directory /var/lib/mysql/first. You can also create a database from the mysql> command prompt with the CREATE DATABASE first DEFAULT CHARACTER SET UTF8; SQL which also allows you to set the default charcter set. You might think you could achieve the same by using –default-character-set=utf8 with the mysqladmin command above but it doesn’t work.

You can get information about a database with this SQL:

mysql> SHOW CREATE DATABASE first;
+----------+----------------------------------------------------------------+
| Database | Create Database                                                |
+----------+----------------------------------------------------------------+
| first    | CREATE DATABASE `first` /*!40100 DEFAULT CHARACTER SET utf8 */ |
+----------+----------------------------------------------------------------+
1 row in set (0.00 sec)

Creating a User

As a user, when you connect to a MySQL server, your identity is determined by the host from which you connect and the username you specify. When you issue requests after connecting, the system grants privileges according to your identity and what you want to do.

You can create MySQL accounts in two ways:

  • By using statements intended for creating accounts, such as CREATE USER or GRANT
  • By manipulating the MySQL grant tables directly with statements such as INSERT, UPDATE, or DELETE

The preferred method is to use account-creation statements because they are more concise and less error-prone.

Operating system usernames are completely unrelated to MySQL usernames which can be a maximum of 16 characters long. Many MySQL clients use the current UNIX username as a default if a username is not specified as a convenience but the two are not related. Likewise MySQL and UNIX account passwords are completely unrelated. MySQL encrypts passwords using its own algorithm. This encryption is different from that used during the Unix login process. MySQL password encryption is the same as that implemented by the PASSWORD() SQL function which you use if you are inserting new users directly into tables - you shouldn’t usually do that though and the GRANT statements mentioned below handle the encryption for you anwyay. Incidentally, UNIX password encryption is the same as that implemented by the ENCRYPT() SQL function.

First, use the mysql program to connect to the server as the MySQL root user (not the same as the root system user):

mysql -u root -p mysql

After connecting to the server as root, you can add new accounts. The following statements use GRANT to set up four new accounts:

mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'localhost'
    ->     IDENTIFIED BY 'some_pass' WITH GRANT OPTION;
mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'%'
    ->     IDENTIFIED BY 'some_pass' WITH GRANT OPTION;
mysql> GRANT RELOAD,PROCESS ON *.* TO 'admin'@'localhost';
mysql> GRANT USAGE ON *.* TO 'dummy'@'localhost';

The accounts created by these GRANT statements have the following properties:

  • Two of the accounts have a username of monty and a password of some_pass. Both accounts are superuser accounts with full privileges to do anything. One account (‘monty’@’localhost’) can be used only when connecting from the local host. The other (‘monty’@’%’) can be used to connect from any other host. Note that it is necessary to have both accounts for monty to be able to connect from anywhere as monty. Without the localhost account, the anonymous-user account for localhost that is created by mysql_install_db would take precedence when monty connects from the local host. As a result, monty would be treated as an anonymous user. The reason for this is that the anonymous-user account has a more specific Host column value than the ‘monty’@’%’ account and thus comes earlier in the user table sort order.
  • One account has a username of admin and no password. This account can be used only by connecting from the local host. It is granted the RELOAD and PROCESS administrative privileges. These privileges allow the admin user to execute the mysqladmin reload, mysqladmin refresh, and mysqladmin flush-xxx commands, as well as mysqladmin processlist . No privileges are granted for accessing any databases. You could add such privileges later by issuing additional GRANT statements.
  • One account has a username of dummy and no password. This account can be used only by connecting from the local host. No privileges are granted. The USAGE privilege in the GRANT statement enables you to create an account without giving it any privileges. It has the effect of setting all the global privileges to ‘N’. It is assumed that you will grant specific privileges to the account later.
  • The statements that create accounts with no password will fail if the NO_AUTO_CREATE_USER SQL mode is enabled. To deal with this, use an IDENTIFIED BY clause that specifies a non-empty password.

Here’s a statement which grants a user custom with password obscure access to just one database bankaccount and only with specific commands:

mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP
    ->     ON bankaccount.*
    ->     TO 'custom'@'localhost'
    ->     IDENTIFIED BY 'obscure';

As of MySQL 5.0.2, you can remove an account and its privileges as follows:

mysql> DROP USER user;

You can find out which privileges a user has with:

mysql> SHOW GRANTS FOR 'root'@'localhost';

To show all grants you could do this:

mysql> SHOW GRANTS;

For just the current user’s grants:

mysql> SHOW GRANTS FOR CURRENT_USER;

You can set passwords like this:

mysql> SET PASSWORD FOR 'jeffrey'@'%' = PASSWORD('biscuit');

Only users such as root that have update access to the mysql database can change the password for other users. If you are not connected as an anonymous user, you can change your own password by omitting the FOR clause:

mysql> SET PASSWORD = PASSWORD('biscuit');

Note

Do you have to FLUSH PRIVILEGES after this??

You can also use a GRANT USAGE statement at the global level (ON .) to assign a password to an account without affecting the account’s current privileges:

mysql> GRANT USAGE ON *.* TO 'jeffrey'@'%' IDENTIFIED BY 'biscuit';

The REVOKE statement enables system administrators to revoke privileges from MySQL accounts:

mysql> REVOKE ALL PRIVILEGES, GRANT OPTION FROM user [, user] ...

The privileges you can set are described here: http://dev.mysql.com/doc/refman/5.0/en/privileges-provided.html

Secure Connections

It is worth noting that data is not encrypted by data between client and server as this is CPU intensive. Find out about secure connections here: http://dev.mysql.com/doc/refman/5.0/en/secure-connections.html

Ubuntu 8.04 Hardy Heron on the MacBook Air

Posted in Desktop Software, Debian, rants, moan by thejimmyg on the June 6th, 2008

<moan>

Personal Problems with Mac OS X

OK, so after a good few months of liking Mac OS X I’ve finally become frustrated with it. Major problems:

  • I can’t find a terminal which doesn’t result in Wuff!! messages when using GNU Screen on Linux. Sounds trivial but is a major problem when I do all of my development remotely with Screen. Instead I use xterm which you can start from the command line of a normal terminal with options to use the lucidia 12 font and white text on black background. This avoids Wuff!! messages but you can’t paste into the terminal unless you connect a mouse which has a middle click (which the touchpad doesn’t) Update See this post for a fix.
  • The X11 supports isn’t great. I use the GIMP, xterm and OpenOffice in particular and get very frustrated when clicking on a window sends it to the back - this is more problematic with lots of windows open
  • I have about 4Gb of email and the Mail app always takes about 5 minutes to realise new mail has arrived even if you click Get New Mail so any time I am expecting an email I have to go back to using http://mail2web.com.
  • A more general point: Most of the time the apps don’t tell you what they are doing (Mail is particularly guilty of this) so there is little useful feedback for the inquisitive. All the features which make the thing useful for new users were just getting in my way.

The main problem though is a personal one. The whole set up is slightly unfamiliar and this means that when something doesn’t work the way I expect it to (particularly when working with remote servers) I have two places where the problem could be rather than one and this makes getting things done harder than it needs to be for me.

The final nail in the coffin for Mac OS X was when I tried to use boot camp to resize the disk a second time to install Ubuntu 8.04 final. The partitioning kept failing and despite all efforts to repair/verify/fix permissions etc (and a crash where the advice was to hold down the off button to reset the computer) I consistently got an error saying the block count of free space was incorrect and couldn’t be fixed. I’m nervous of any sort of disk error which can’t be fixed so I backed up all my data and reformatted.

oh-dear.png

Another rant: Once you’ve tried to reinstall an operating system a couple of times in a few days some of the "features" which were really fun when I first booted the MacBook Air became a real pain. Sitting through the welcome video with its happy tune when all you want to do is get on with real work is not a lot of fun. Likewise having to fill in the registration form again with the same details is tiresome. Not being able to skip the photo setting stage is just silly.

Lessons Learned from the Reinstall

  • Debian Etch just won’t install at all (all key presses on the installation wizard get sent twice and you can’t have the CD-ROM drive and a keyboard both plugged in at once)
  • The Mac OS X installation doesn’t prompt you for the second CD (it just spits it out) so the first time I reinstalled I waited for an hour whist the progress bar kept animating without realising it was waiting for my input - that was frustrating.
  • Removing the 3.4GB printer drivers Mac OS X sets up for you saves a lot of space as does removing the GB of extra languages.
  • You can’t create Mac OS X in a small partition and expect to be able to install Hardy in the free space and still have it still show up when you hold down Alt at boot - the Mac doesn’t find the Hardy partition.
  • You can’t install Mac OS X to the full partition, boot camp it back down and then change the partitioning scheme to include swap space - again, this results in the Mac not recognising the boot screen

Update: It sounds like playing around with http://refit.sourceforge.net/ probably would have helped here.

This meant I was left with the option of dual boot without swap or removing Mac OS X. For the time being I’ve gone with losing Mac OS X and just sticking with the complete hard disk given over to Ubuntu. Luckily this does work!

On to the Ubuntu on Air Part

These are the main sites you need to look at and they are constantly being updated with more information:

There is some information which might be helpful here too:

Download the 8.04 CD and burn it to a CD using Disk Utility in the Utilities folder of Applicaitons on Mac OS X. Next install Ubuntu using the whole disk and destroying Mac OS X and all your data (if that is what you want) then get the wireless drivers working…

Log in and follow the instructions to get and install unrar and the ndiswrapper files. Get the broadcom driver from the Mac OS X cd then run these commands:

cd Desktop/broadcom
chmod u+w .
unrar x broadcomxpinstaller.exe
sudo ndiswrapper -i bcmwl5.inf
sudo ndiswrapper -l
sudo ndiswrapper -m
sudo modprobe ndiswrapper

Edit /etc/modules and add ndiswrapper as the last line and then save the file. Wireless should work without a reboot so you can choose the network and enter the WEP key (remembering to choose WEP 128bit Hex if you are using a hex key).

The big problem I had with networking on Ubuntu is that it uses NetworkManager which uses D-Bus and HAL extensively and is configured via an applet which loads in the GNOME panel (the command is started with nm-applet –sm-disable if you are interested). This works absolutely perfectly in GNOME but I’m using XFce and no command line interface exists to configure the network directly (although cnetworkmanager might eventually work but doesn’t at the moment). NetworkManager doesn’t use the usual /etc/network/interfaces file so the only solution is to load the gnome-panel from a terminal in Xfce, run the nm-admin –sm-disable command manually, configure the network then kill the panel again. This is really silly but until a command line utility exists this was the only solution I could find. There is an Xfce applet which lets you run GNOME applets in the Xfce panel but the nm-applet applet is not one of the ones listed to add. Personally I love the fact the networking works so easily but I really, really object to the way it can only be configured through a GUI applet. This seems to go very much against UNIX principles and might be a slippery slope that the community really shouldn’t be going down. Then again, I might just be missing something obvious to the rest of the world!

The touchpad is more of a problem. I couldn’t get touchd to compile despite installing these: sudo apt-get install libdbus-glib-1-dev libdbus-1-dev libglib2.0-dev and running modprobe uinput doesn’t create the /dev/mouse/uinput file which is supposed to exist so I created the touchpad.sh script and assigned it to F4 using gconf-editor and the instructions here: http://ubuntuforums.org/showpost.php?p=429683&#038;postcount=1 in B1. Whilst this works (just) in Gnome it isn’t much use in Xfce so I’m just using an external mouse until someone fixes this one.

Sound works fine but the microphone doesn’t.

Here are the commands I needed for mounting the MyBook using Samba and the FreeAgent which now has a (read only) hfs+ filesystem because I had to format it when the FAT 32 filesystem would only work intermittently on Mac OS X.

sudo mkdir /mnt/mybook
sudo mkdir /mnt/freeagent
sudo smbmount //192.168.1.10/PUBLIC /mnt/mybook
sudo mount -t hfsplus /dev/sdb1 /mnt/freeagent

That’s it so far. The essentials of a web browser and being able to copy and paste to working terminal are working perfectly now and I can access all my data. Not much else is working but then again, I don’t need it to. I’ll keep adding to this as I find more things that work.

Lots of the custom codecs and plugins wouldn’t install correctly without:

touch /home/james/.Xauthority
chown james:james /home/james/.Xauthority

</moan>

MyBook World

Posted in Python, Hardware by thejimmyg on the June 5th, 2008

I’ve been hacking the MyBook World Edition recently (it runs a fairly standard linux with LightHTTPd, Perl etc). Here are some notes.

First, here is the main site with all the tips: http://mybookworld.wikidot.com/hacks-and-howto

Installation

Follow either of the two setup methods. I used this:

http://martin.hinner.info/mybook/sshaccess.php

You need to create a user first though and then log in as that user. In my case that meant SSHing in as JAMES@… because the username was created in upper case.

Installing the Software

You don’t need the included CD-ROM at all. The MyBook runs samba already so you just mount the share as normal using the username and password of the user you set up. For example on the Mac in finder you choose Go->Connect to server and type smb://<ip-address>/PUBLIC to mount the PUBLIC share which is already created. Files created here are actually stored at /shares/internal/PUBLIC.

Because the MyBook supports SSH once you’ve set it up you can also mount the drive via MacFUSE.

Since you aren’t using MioNet it is possible to disable it http://martin.hinner.info/mybook/disable_mionet.php. The script is a bit longer on more recent MyBook World’s like mine but the line to comment is still there.

Copying Files

Copying files to the MyBook is very slow over Wifi with Samba (1TB is a lot of space after all) but using rsync seems a little faster than samba. Using a network cable is a lot faster. It would be nice if Western Digital threw in a USB cable for the 150 pounds but they don’t so I’m not sure how fast transfers would have been over USB. Either way it can take a couple of days of transferring files to fill the MyBook.

Dynamic DNS

  • Get an account with dyndns.com

  • Download and install the ddclient-3.7.3 software

  • Extract the files and delete the first line of the ddclient program so that it executes with /usr/local/bib/perl

  • Symlink ln -s /root/ddclient-3.7.3/ddclient /usr/sbin/ddlclient

  • Add a line to /etc/inittab which looks like this:

    ::sysinit:/usr/sbin/ddclient -daemon=0 -file=/root/ddclient-3.7.3/jg.conf
    

The file is shown below:

# Basic configuration file for ddclient
#
# /etc/ddclient.conf
daemon=600
cache=/tmp/ddclient.cache
pid=/var/run/ddclient.pid
use=web, web=checkip.dyndns.com/, web-skip='IP Address'
login=mybook
password=xxxxxx
protocol=dyndns2
server=members.dyndns.org
wildcard=YES
mybook.dontexist.org

You can also install ddclient as a package I believe. One thing to note is that if for any reason the network isn’t working when the MyBook is turned on, the program won’t be able to update the IP and since we’re not running it as a daemon it won’t keep checking so you will be left with the domain pointing to an IP address which isn’t correct.

Useful Links:

Tip

For testing on a Mac OS X Leopard you can flush the DNS cache with dscacheutil -flushcache

Static Routing and Port Forwarding

Once dynamic DNS is working you will probably want to be able to access the box from the outside world. If you have plugged the MyBook into your home network you are almost certainly running behind a NAT router which is responsible for routing requests sent to the IP of the ADSL modem to the correct IP of the home private network. This means that the IP just assigned via dynamic DNS is the IP of the ADSL modem/router, not the MyBook so you can’t yet access the MyBook from outside the home network to do this use port forwarding,

Log in to your router’s admin web interface (it will be on port 80 at the IP the dynamic dns configuration has just set) and look up the LAN clients. There will be one with a hostname of MyBookWorld. Now go to the port forwarding screen of the web interface and forward port 22 to the IP address of the MyBook. Now all requests to the router on the SSH port will go to the MyBook so you can access it from the outside world.

The MyBook gets its IP address via DHCP so every time you turn off your router and MyBook you might get a different IP address on the local network. To fix this go to the MyBook’s web interface and run the networking wizard to set up static routing. Choose the IP address the MyBook already has (or another one if you don’t mind setting up port forwarding again) and be sure to enter the IP address (on the local network) of the ADSL modem/router (usually 192.168.1.1 or 192.168.0.1) in the gateway section otherwise the dynamic DNS client won’t know how to resolve domain names and will therefore fail.

Tip

Setting up things manually via /etc/network/interfaces doens’t work since these settings seem to get over-written.

Setting Up Package Management

feed=http://ipkg.nslu2-linux.org/feeds/optware/gumstix1151/cross/unstable
ipk_name=$(wget -qO- $feed/Packages | awk '/^Filename: ipkg-opt/ {print $2}')
wget $feed/$ipk_name
tar -xOvzf $ipk_name ./data.tar.gz | tar -C / -xzvf -
sed -i -e 's|/stable|/unstable|' /opt/etc/ipkg.conf

Add a new library path:

echo "/opt/lib" >>/etc/ld.so.conf
ldconfig

Check it is there:

ldconfig -v

Then it’s all fun:

Update local feed lists - you need to issue this from time to time to get package updates:

/opt/bin/ipkg update

See what’s available, sort descriptions included:

/opt/bin/ipkg list

See what’s already installed:

/opt/bin/ipkg list_installed

Install or upgrade packages:

/opt/bin/ipkg install <foo> <bar>

Installing Python

I want to install Python 2.5 so I type this to output all packages with python in the name or desciprtion:

/opt/bin/ipkg list | grep python

The package I want is called python25 so it is installed like this:

/opt/bin/ipkg install python25

The downloading part seems to take a long time, maybe the packages are on a slow server:

[root@MyBookWorld ~]#   /opt/bin/ipkg install python25
Installing python25 (2.5.2-2) to /opt/...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/gumstix1151/cross/unstable/python25_2.5.2-2_arm.ipk
Installing readline (5.2-2) to /opt/...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/gumstix1151/cross/unstable/readline_5.2-2_arm.ipk
Installing bzip2 (1.0.5-1) to /opt/...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/gumstix1151/cross/unstable/bzip2_1.0.5-1_arm.ipk
Installing openssl (0.9.7m-4) to /opt/...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/gumstix1151/cross/unstable/openssl_0.9.7m-4_arm.ipk
Installing libdb (4.2.52-3) to /opt/...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/gumstix1151/cross/unstable/libdb_4.2.52-3_arm.ipk
Installing zlib (1.2.3-2) to /opt/...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/gumstix1151/cross/unstable/zlib_1.2.3-2_arm.ipk
Installing sqlite (3.5.9-1) to /opt/...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/gumstix1151/cross/unstable/sqlite_3.5.9-1_arm.ipk
Installing ncurses (5.6-3) to /opt/...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/gumstix1151/cross/unstable/ncurses_5.6-3_arm.ipk
Installing libstdc++ (6.0.3-6) to /opt/...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/gumstix1151/cross/unstable/libstdc++_6.0.3-6_arm.ipk
Installing ncursesw (5.6-2) to /opt/...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/gumstix1151/cross/unstable/ncursesw_5.6-2_arm.ipk
Configuring bzip2
update-alternatives: Linking //opt/bin/bzip2 to /opt/bin/bzip2-bzip2
Configuring libdb
Configuring libstdc++
Configuring ncurses
update-alternatives: Linking //opt/bin/clear to /opt/bin/ncurses-clear
Configuring ncursesw
Configuring openssl
Configuring python25
Configuring readline
Configuring sqlite
Configuring zlib
Successfully terminated.
[root@MyBookWorld ~]# /opt/bin/python2.5
/opt/bin/python2.5: can't load library 'libpython2.5.so.1.0'
[root@MyBookWorld ~]# ldconfig
[root@MyBookWorld ~]# /opt/bin/python2.5
Python 2.5.2 (r252:60911, Feb 26 2008, 19:30:31)
[GCC 3.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>

Notice that I had to run ldconfig again before the python2.5 executable worked. I also link /usr/bin/python to the current executable so I don’t have to keep typing the path to /opt/bin:

[root@MyBookWorld ~]# ln -s /opt/bin/python2.5 /usr/bin/python
[root@MyBookWorld ~]# python
Python 2.5.2 (r252:60911, Feb 26 2008, 19:30:31)
[GCC 3.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>

Edna MP3 Server

wget http://surfnet.dl.sourceforge.net/sourceforge/edna/edna-0.6.tar.gz tar zxvf edna-0.6.tar.gz cd edna-0.6.tar.gz cp edna.conf edna.conf.bak

Then edit edna.conf to set the paths to look for MP3s. Mine was:

# Unix example:
dir1 = /shares/internal/PUBLIC/Music = MP3 CDROM

Now serve it:

[root@MyBookWorld edna-0.6]# python edna.py
edna: Ogg Vorbis support disabled, to enable it you will need to install the "pyogg" and the "pyvorbis" modules
edna: serving on port 8080...

and visit the server at http://<your-myboook-ip>:8080/ It does run very slowly but it works.