2010 01 14

I own an Apple iPod Nano and I use it mostly everyday to listen to music in the car. I add that I also use iTunes to manage my music collection and I like it a lot.

A few months ago, I stumbled upon a new feature of iTunes called Genius Mix which essentially “explores your library and finds songs that go great together.” The major issue was that Genius Mix requires an iTunes store account which, well, we, Mauritians, can’t have… except that Mauritius Telecom has been nice enough to explain how to get one, ahem, obliquely.

I am happy to say that Genius Mix works fantastically well. It works by analysing the numerous playlists being created by real human beings all other the planet and being submitted to the iTunes store. Then Genius Mix builds similar playlists locally using songs found in your library only (of course.)

When I launch iTunes now, I am greeted with the selection shown above and I can easily choose whether to indulge into some Electronica, Brit-Pop/Rock, Synth-Pop, Pop, Techno/House, New Wave, Post Punk, Hip-Hop/Rap, Dance Pop, Classic Rock, Punk or Europop.

Life is cool. I have my own DJ. And she knows what I like.

Popularity: 1% [?]

  • Share/Bookmark

written by avinash

2009 11 02

20091102-macbook-dns-323

The D-Link DNS-323 NAS is great. It runs Linux, is infinitely tweakable and plays nicely with most devices I have at home including my MacBook, my Linux boxes and my Wii running MPlayer CE which I use to watch DivX on my TV.

The only problem I had was that the NAS only offered SMB (via Samba) out of the box which meant that some operations were somewhat slow when initiated from my MacBook. For instance, deletes were slow even though transfer speeds were great. After reading some posts online, I realised that the solution was to activate AFP (Apple Filing Protocol) as well as Multicast DNS (Bonjour) on the NAS. AFP is provided by Netatalk and Bonjour by Avahi.

Of course, to install new software on the DNS-323, you must have fun_plug properly activated.

Installing Avahi on the DNS-323

1) Get libdaemon and avahi.

Install both with

funpkg -i libdaemon-0.13-1.tgz
funpkg -i avahi-0.6.24-1.tgz

2) Add an avahi user

groupadd -g 50 avahi
useradd -u 50 -g avahi -d /tmp -s /bin/false avahi

3) Create a startup script called /ffp/start/avahi.sh as shown here.

#!/ffp/bin/sh

# PROVIDE: avahi
# REQUIRE: SERVERS

. /ffp/etc/ffp.subr

name="avahi"
command="/ffp/sbin/avahi-daemon"
avahi_daemon_flags="-D -s"
required_files="/ffp/etc/avahi/avahi-daemon.conf /ffp/etc/avahi/hosts"

start_cmd="avahi_start"

avahi_start()
{
	# need avahi user and group for priviledge separation
	if ! grep '^avahi:' /etc/passwd >/dev/null; then
	        echo 'avahi:x:50:50:Avahi Daemon:/no/where:/bin/false' >>/etc/passwd
	fi
	if ! grep '^avahi:' /etc/shadow >/dev/null; then
	        echo 'avahi:*:14493:0:99999:7:::' >>/etc/shadow
	fi
	if ! grep '^avahi:' /etc/group >/dev/null; then
	        echo 'avahi::50:avahi' >>/etc/group
	fi

	proc_start $command
}

run_rc_command "$1"

4) Make the file executable so that avahi starts when the DNS-323 boots

chmod +x /ffp/start/avahi.sh

5) Create /ffp/etc/avahi/services/smb.service

<?xml version="1.0" standalone="no"?><!--*-nxml-*-->
<service-group>
        <name replace-wildcards="yes">%h</name>
        <service>
                <type>_smb._tcp</type>
                <port>445</port>
        </service>
</service-group>

6) Create /ffp/etc/avahi/services/http.service

<?xml version="1.0" standalone="no"?><!--*-nxml-*-->
<service-group>
        <name replace-wildcards="yes">%h</name>
        <service>
                <type>_http._tcp</type>
                <port>80</port>
        </service>
</service-group>

7) Create /ffp/etc/avahi/services/device-info.service (This changes the ICON shown in Mac OS X)

<?xml version="1.0" standalone="no"?><!--*-nxml-*-->
<service-group>
        <name replace-wildcards="yes">%h</name>
        <service>
                <type>_device-info._tcp</type>
                <port>0</port>
                <txt-record>model=RackMac</txt-record>
        </service>
</service-group>

8 ) Launch avahi

/ffp/start/avahi.sh

Installing AFP (netatalk) on the DNS-323

1) Get db42 and netatalk and install both with

funpkg -i db42-4.2.52-1.tgz
funpkg -i netatalk-2.0.4-1.tgz

2) Create a startup script called /ffp/start/afpd.sh as shown here.

#!/ffp/bin/sh

# PROVIDE: afpd
# BEFORE:
# REQUIRE:

. /ffp/etc/ffp.subr

name="afpd"
start_cmd="afpd_start"
stop_cmd="afpd_stop"
status_cmd="afpd_status"

afpd_start()
{
    /ffp/sbin/afpd
}

afpd_stop()
{
    killall afpd
}

afpd_status()
{
    ps -A | grep /ffp/sbin/afpd | grep -v grep
}

run_rc_command "$1"

3) Make it executable with

chmod +x /ffp/start/afpd.sh

4) Create /ffp/etc/avahi/services/afpd.service as show here.

<?xml version="1.0" standalone="no"?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">

<service-group>

<name replace-wildcards="yes">%h</name>

<service>
<type>_afpovertcp._tcp</type>
<port>548</port>
</service>

</service-group>

5) Use the “vipw” command and change some details for the default “nobody” user so that Mac OS X can use that user to log in.

nobody:x:501:501:Linux User,,,:/home/nobody:/ffp/bin/bash

Give a password to that user and store the password (in clear text) in the user’s home directory as shown here.

passwd nobody
cd /home
mkdir nobody
echo "secret" > nobody/.passwd
chown -R nobody: nobody

It is essential to store this user’s information in the flash memory of the DNS-323. Do this with:

store-passwd.sh

6) Modify /ffp/etc/netatalk/AppleVolumes.default to add the required shares. Mine looks like:

# The "~" below indicates that Home directories are visible by default.
# If you do not wish to have people accessing their Home directories,
# please put a pound sign in front of the tilde or delete it.
# ~     

/mnt/HD_a2 Volume_1
/mnt/HD_b2 Volume_2

Notice that I have commented the ~ because I don’t want the user to have a home directory on the DNS-323. I only want to access Volume_1 and Volume_2.

7) Start netatalk

/ffp/start/afpd.sh start

Making Mac OS X Leopard play nice with Netatalk

To allow Leopard to connect to AFP shares with clear text (unencrypted) passwords, do as shown here:

# to be done on the Mac and not the DNS-323
sudo defaults write com.apple.AppleShareClient "afp_cleartext_allow" -bool YES
sudo defaults write com.apple.AppleShareClient "afp_cleartext_warn" -bool YES

Enjoy!

You can now connect to the DNS-323 from a Mac and get optimal performance. Phew. Linux is sooooo fun… for geeks like me :-)

5 November 2009 update: Instead of creating a new user, the existing user “nobody” is used. This allows the DNS-323 to be used through AFP and SMB transparently as SMB uses “nobody” by default. Interestingly, when the DNS-323 reboots, its /home directory starts anew and therefore will lack a /home/nobody directory (with its .passwd file) but this does not seem to trouble Mac OS X.

Popularity: 1% [?]

  • Share/Bookmark

written by avinash

2009 09 09

20090909-printing-press

I generally use my MacBook (running Mac OS X 10.5 Leopard) at work and it is essential for me to be able to print documents on my network printers attached to a Linux CUPS server (running CentOS Linux 5.3.)

What needs to be done on the Mac OS X Leopard computer

For some reason, Leopard cannot see printers shared by CUPS by default (it only sees Bonjour printers.) To rectify this, open a terminal and type:

sudo vi /etc/cups/cupsd.conf

and add “BrowseProtocols all” so that the file looks like this:

# Enable printer sharing and shared printers.
Browsing On
BrowseOrder allow,deny
BrowseAllow all
BrowseAddress @LOCAL
BrowseProtocols all
DefaultAuthType Basic
<Location />
# Allow shared printing…
Order allow,deny
Allow @LOCAL
</Location>
# Enable printer sharing and shared printers. Browsing On BrowseOrder allow,deny BrowseAllow all BrowseAddress @LOCAL BrowseProtocols all DefaultAuthType Basic &lt;Location /&gt;  # Allow shared printing...  Order allow,deny  Allow @LOCAL &lt;/Location&gt;

Then restart the CUPS daemon running on the Mac with

sudo launchctl unload /System/Library/LaunchDaemons/org.cups.cupsd.plist sudo launchctl load /System/Library/LaunchDaemons/org.cups.cupsd.plist

What needs to be done on the Linux server

Modify /etc/cups/cupsd.conf so that its beginning somewhat looks like this:

# Share local printers on the local network. Browsing On BrowseOrder allow,deny BrowseAddress @LOCAL DefaultAuthType Basic &lt;Location /&gt;   # Allow shared printing...   Order allow,deny   Allow @LOCAL &lt;/Location&gt;

and restart the CUPS server with one of:

/etc/init.d/cups restart /etc/init.d/cupsd restart

and everything should work from there. Go on your Mac and add your Linux printers in the usual way.

One observation I made

Printing generally works great but sometimes stop working when either the Mac or the Linux server are updated. What happens is that, during the update, the CUPS configuration (/etc/cups/cupsd.conf) gets slightly changed to something much more restrictive for security reasons (i.e. network printing is disabled.) I guess this is because both the Apple and Linux people think that it’s better be prudent than sorry especially in our era of fully opened Wifi network.

You’ve been warned :-)

Popularity: 1% [?]

  • Share/Bookmark

written by avinash