DSM-G600, DNS-3xx and NSA-220 Hack Forum

Unfortunately no one can be told what fun_plug is - you have to see it for yourself.

You are not logged in.

Announcement

#1 2007-05-24 23:08:51

ihakes
Member
Registered: 2007-05-24
Posts: 10

iTunes Server hacks

I'd like to create a howto page on the main wiki with information on how to hack the DNS-323 iTunes webserver.

My request comes because I haven't found any easy description of how to modify the existing mt-daapd server (rather than upgrading to Firefly 1.0).

My first hack (and the one that prompted my digging into my DNS with the fun_plug) was to add playlists to the shared iTunes server. When I first fired up the server and could get access to my shared music files, my first thought was "great!" My second was "where are these playlists coming from? I don't want a '60's Music' playlist."

So low and behold here is what I've done to get the iTunes server on the DNS-323 working my way.

1. Set up the FTP server and copied over the fun_plug file
2. Restarted the DNS-323 and tested that the fun_plug gave the dmesg.out file
3. Downloaded the telnet files (leaving out the fun_plug included in the tar.gz file) and copied over the 3 important files to the DNS-323 root (/) directory
4. Restarted the DNS-323
5. Used puTTY to log in via telnet from my Windows machine
6. Tracked down the iTunes playlist at /etc/mt-daapd.playlist and edited it to my whims. I used the vi editor to make the changes, but specific instructions on how to do that may be beyond the scope of this document.
7. Saved the changed file and refreshed the iTunes server from the DNS-323 web admin tool
8. Networked systems then see the new playlists in their iTunes.

My playlist changes were based on the outline from http://en.opensuse.org/ITunes.

I've included a slightly updated mt-daapd.playlist file so you can see what I've done. If something gets messed up with your changes and you need to revert, you can copy over using the original DNS-323 file, which is located at /default/mt-daapd.playlist.

Cheers,
Ian

Offline

 

#2 2007-05-25 00:40:51

ihakes
Member
Registered: 2007-05-24
Posts: 10

Re: iTunes Server hacks

Two problems have cropped up since my post above:

1. After a reboot of the DNS-323, my customized playlist was wiped out and replaced by the default playlist again. Anyone know how to keep this from happening?

2. Some, but not all, of the music shared from the iTunes server is listed twice when viewed from the networked computers. There's only one actual copy of the file on the DNS-323, but the server is showing it twice. I've no idea why.

Offline

 

#3 2007-05-25 08:17:12

ihakes
Member
Registered: 2007-05-24
Posts: 10

Re: iTunes Server hacks

I figured out what happened to cause #2 in my 14:40 post. The database file used by the mt-daapd server had been corrupted (very likely by me poking around).

If you find yourself in a similar situation -- where the files showing up on your shared iTunes server are doubled, or missing, even though you know there's only one copy -- here's how to rectify the problem:

1. Disable the iTunes server in the DNS-323 web interface
2. Telnet into your system using puTTY or another telnet client
3. Open (or use the 'cat' command to view) the /etc/mt-daapd.conf file. Look for the filesystem location specified in the line starting with "db_dir" -- by default this is located at /mnt/HD_a2/.systemfile/.mt-daapd
4. Change ('cd') to that directory
5. Do an "ls -a" (that's a lowercase L) on the directory and you should see a .songs.gdb file (this file is hidden, so we have to use the -a switch to see if it's actually there). This is the file used by the iTunes server to know what files are available. Don't try to read it, as it's not an ASCII file, and doing so will only corrupt it (if it wasn't before)
6. Delete (or simply rename) that .songs.gdb file
7. Go back to the DNS-323 web interface for the iTunes server and re-enable the server
8. Click the "Refresh" button and the server will rebuild that .songs.gdb file
9. Once the Refresh window says "Refreshed Successfully", then your iTunes server is back in business. Check through your networked iTunes clients, and the correct songs should now show up!

GL!

Offline

 

#4 2007-05-25 08:31:11

DNS-323 Talker
Member
Registered: 2007-05-21
Posts: 245

Re: iTunes Server hacks

Thanks for posting all this info...I'm not quite ready to make use of it, but it is great to have all the detailed information.  If this isn't in the Wiki you should consider adding it there...happy tunes to you.  smile


DNS-323 w/two Seagate 500 GB RAID1
Fonz's Fun_Plug- Don't DNS-323 without it!

Offline

 

#5 2007-05-25 20:12:03

ihakes
Member
Registered: 2007-05-24
Posts: 10

Re: iTunes Server hacks

No problem -- I'm glad to post my workings if they help someone else out.

I don't have the ability to add a new page to the wiki though, which is why I've added it here. If you can create an iTunes page under the howto branch of the wiki, then I believe I can edit it.

Offline

 

#6 2007-05-25 20:24:44

DNS-323 Talker
Member
Registered: 2007-05-21
Posts: 245

Re: iTunes Server hacks

I haven't done any Wiki editing (newbie) so don't know about that...hopefully someone else reading this will post some help in that area..


DNS-323 w/two Seagate 500 GB RAID1
Fonz's Fun_Plug- Don't DNS-323 without it!

Offline

 

#7 2007-05-26 00:43:38

ihakes
Member
Registered: 2007-05-24
Posts: 10

Re: iTunes Server hacks

The saga continues...

I've done some more poking around with regards to the playlist file being overwritten after a reboot. Here's what I've found:

During the reboot, the rc.sh file copies the mt-daapd.playlist file from /sys/mtd1/ to /etc/ (where it is used by the mt-daapd (iTunes) process). However, simply putting the updated file into the /sys/mtd1/ folder (the mt-daapd.conf configuration file is also kept there) does not work. It seems to be erased somehow during the boot process.

Also, putting the updated playlist file into the /default/ folder doesn't work either.

So, does anyone know how to get/keep an altered file in the /sys/mtd1/ folder so that it is copied during the reboot process?

Offline

 

#8 2007-05-26 01:06:34

DNS-323 Talker
Member
Registered: 2007-05-21
Posts: 245

Re: iTunes Server hacks

I assume you tried simple things like setting it read-only?


DNS-323 w/two Seagate 500 GB RAID1
Fonz's Fun_Plug- Don't DNS-323 without it!

Offline

 

#9 2007-05-26 01:28:08

ihakes
Member
Registered: 2007-05-24
Posts: 10

Re: iTunes Server hacks

Yeah -- doesn't work to chmod the /etc/mt-daapd.playlist file to 555. Just gets wiped on the reboot.

There must be some file, modified when the web interface is used, that tells the DNS-323 to use the /sys/mtd1/ version of a file rather than the one in the defaults folder. That's why the modified mt-daapd.conf file can stay in there and be used. (If you compare with the /defaults/mt-daapd.conf file, the difference is that /sys/mtd1/mt-daapd.conf file has the path to your iTunes music folder).

Augh! The answer seems so close -- it must be there somewhere!

Offline

 

#10 2007-05-26 01:31:37

DNS-323 Talker
Member
Registered: 2007-05-21
Posts: 245

Re: iTunes Server hacks

what about storing the "right" version of the file somewhere and copying it over the one that the DNS-323 puts there after reboot.  You could run a fun_plug script to do the copy on restart.

I'm new to all of this, was that a stupid idea?  Don't worry about hurting my feelings, I know I'm in over my head.  smile


DNS-323 w/two Seagate 500 GB RAID1
Fonz's Fun_Plug- Don't DNS-323 without it!

Offline

 

#11 2007-05-26 02:57:09

ihakes
Member
Registered: 2007-05-24
Posts: 10

Re: iTunes Server hacks

I was already halfway there -- I put my playlist into my externally accessible Volume_1 folder, so I could edit it there, and have a backup copy in case of a reboot. Then I was just using the telnet session to copy the file into the /etc/ directory.

I like the suggestion of adding it to the fun_plug though, I hadn't thought of that.

Here's the lines I added to my fun_plug script:

# Fix the iTunes playlists
cp /mnt/HD_a2/mt-daapd.playlist /etc/mt-daapd.playlist
chown root.root /etc/mt-daapd.playlist


The copying worked, but it looks like the mt-daapd is started before the fun_plug gets run, because the iTunes server still shows the default set of playlists. After "Refreshing " the iTunes server in the interface, the new playlist shows up.

The programmer in me still cries out for a more integrated, elegant solution, but this hack definitely gets the job done.

Offline

 

#12 2007-05-26 03:04:20

ihakes
Member
Registered: 2007-05-24
Posts: 10

Re: iTunes Server hacks

And in case anyone's interested in some playlist samples showing off different tagging searches, here are a few from my file:


"90's Music" {
    Year >= 1990 && Year < 2000
}

Plays music with the Year tag from 1990 to 1999


"Pink Floyd (all)" {
    Artist is "Pink Floyd"
}

All songs by Pink Floyd


"Live U2" {
    Artist is "U2" &&
    Genre is "Live"
}

All music by U2 and has a Genre tag of "Live"


"Ambient" {
    Genre is "Ambient" ||
    Genre is "Electronica"
}

All my music that has a Genre tag of Ambient or Electronica.

I hope all this helps someone now or in the future.

Cheers,
Ian

Last edited by ihakes (2007-05-26 03:05:46)

Offline

 

#13 2007-05-26 03:24:32

DNS-323 Talker
Member
Registered: 2007-05-21
Posts: 245

Re: iTunes Server hacks

Well, elegant is preferred, but having brute force to fall back on is sometimes important.  Good luck working out a better solution...I'm tapped out.


DNS-323 w/two Seagate 500 GB RAID1
Fonz's Fun_Plug- Don't DNS-323 without it!

Offline

 

#14 2007-05-26 03:36:43

fonz
Member / Developer
From: Berlin
Registered: 2007-02-06
Posts: 1716
Website

Re: iTunes Server hacks

ihakes wrote:

The copying worked, but it looks like the mt-daapd is started before the fun_plug gets run, because the iTunes server still shows the default set of playlists. After "Refreshing " the iTunes server in the interface, the new playlist shows up.

Try sending SIGHUP to mt-daapd.

Code:

killall -HUP mt-daapd

Offline

 

#15 2007-06-02 01:56:28

ihakes
Member
Registered: 2007-05-24
Posts: 10

Re: iTunes Server hacks

Code:

killall -HUP mt-daapd

doesn't work because the 'killall' program isn't found on the system, and using 'kill' won't work because there's multiple process IDs and no 'sed' program to cut out just the PID value.

I tried

/usr/sbin/mt-daapd restart

and even a

kill -HUP 1015

(where 1015 was the primary process ID for the mt-daapd), but neither of those picked up the new playlist file either.

Offline

 

#16 2007-06-02 02:39:15

fonz
Member / Developer
From: Berlin
Registered: 2007-02-06
Posts: 1716
Website

Re: iTunes Server hacks

There are still options:

- Install a funplug with killall
- run busybox binary. it'll list built-in commands. if it supports killall, create a symlink "ln -s busybox killall"
- loop over processes, e.g. like this:

Code:

for x in $(ps | grep a | grep -v grep | cut -d' ' -f1); do kill -HUP $x; done

btw, the above loop won't work very well, it's meant to inspire :-)

Last edited by fonz (2007-06-02 02:42:23)

Offline

 

#17 2007-07-26 08:45:19

Krtek
New member
From: Bielefeld
Registered: 2007-07-26
Posts: 1

Re: iTunes Server hacks

Maybe this is the original source dir of the playlist file: /sys/crfs/default
This fs is mounted R/O, so I could not mod the file yet. Will keep on trying...


Meanwhile I found a better solution:

Inspired by fonz store-password.sh script (taken from version 0.3), I created my own store-mt-daapd.playlist.sh script. This will make changes to /etc/mt-daapd.playlist survive a reboot (tested with fw 1.03).

This is the recommend usage:
- edit /etc/mt-daapd.playlist according to your personal needs (watch out for CR/LF problem; do not use notepad to edit!)
- refresh the itunes lib via DNS web GUI
- check in itunes, if your requirements to the playlists are fulfilled
- if the playlist suits your needs, call store-mt-daapd.playlist.sh

Usual disclaimer: use at your own risk...

#!/bin/sh

echo "Copying mt-daapd.playlist to mtd1..."
mount -t minix /dev/mtdblock0 /sys/mtd1
cp -f /etc/mt-daapd.playlist /sys/mtd1
sync
umount /sys/mtd1

echo "Copying mt-daapd.playlist to mtd2..."
mount -t minix /dev/mtdblock1 /sys/mtd2
cp -f /etc/mt-daapd.playlist /sys/mtd2
sync
umount /sys/mtd2

echo "Done."

Last edited by Krtek (2007-07-29 07:44:37)

Offline

 

#18 2007-08-16 22:49:39

edward3h
Member
Registered: 2007-08-16
Posts: 14

Re: iTunes Server hacks

I had a quick look at the source for mt-daapd, and it looks like it does not read playlists when it gets a HUP signal, it just does the check for new or changed mp3 files. It only reads the playlists on startup. (I don't know whether that has changed in newer versions of firefly).

Offline

 

#19 2007-08-17 17:58:28

edward3h
Member
Registered: 2007-08-16
Posts: 14

Re: iTunes Server hacks

I tried a little experiment yesterday. Basically I had a startup script which copied over my playlists, then did
killall mt-daapd
mt-daapd

in an attempt to restart the iTunes server. For some reason this led to the box broadcasting on Bonjour/Rendezvous/Avahi/whatever its IP address as the default 192.168.0.32, even though it had another address assigned from DHCP. This meant that iTunes on another machine showed an entry for it, but couldn't actually reach it. Weird. So I'm not sure if this will work, or if mt-daapd needs some other options provided to it.

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2010 PunBB