Mediatomb on Ubuntu - init script
Cyclonite
Tampa, Florida Icrontian
I'm hopin' one of you linux gods can help me here. I don't profess to know what I'm doing in Linux. I've tried a couple different distros at different points in my life, and right now I'm using Ubuntu 7.10.
I installed Mediatomb using the instructions from their website for the Feisty install. After installing, I prepped the config.xml and launched the server. It worked great. I can browse to the WebUI and add the directories. My PS3 recognizes it and the music streams just fine.
Now on to my problem. I want this to run at startup as a service (daemon?), so I took a look around and found I have to use an init script. One is included when you install Medatomb, and it's already placed in /etc/init.d. So I take a look at it and alter the required settings. My issue comes when it tries to run at startup. At first it was giving me the UPnp Error -117 referenced in the documentation on the site. SO I decided to follow the instructions:
The init script adds this when you specify an interface in /etc/default/mediatomb. This is where my next problem comes in: It gives me an error saying it cannot find the specified interface. Specifically, eth1. This is the interface my network cable is connected to, and it has an IP address.
I assumed the interface may not have been fully up yet, so I tried to delay the script startup. I'm not sure if I was successful in delaying it, but either way, I still get the error.
I tried specifying the loopback interface "lo" for the init script, and the server starts up without a hitch. Obviously that doesn't help me share files, but maybe it'll help someone point me in the right direction.
Thanks in advance for your help. I can provide any output you may need. You might have to tell me how to get it though.
I installed Mediatomb using the instructions from their website for the Feisty install. After installing, I prepped the config.xml and launched the server. It worked great. I can browse to the WebUI and add the directories. My PS3 recognizes it and the music streams just fine.
Now on to my problem. I want this to run at startup as a service (daemon?), so I took a look around and found I have to use an init script. One is included when you install Medatomb, and it's already placed in /etc/init.d. So I take a look at it and alter the required settings. My issue comes when it tries to run at startup. At first it was giving me the UPnp Error -117 referenced in the documentation on the site. SO I decided to follow the instructions:
4.1. Network Setup
Some systems require a special setup on the network interface. If MediaTomb exits with UPnP Error -117, or if it does not respond to M-SEARCH requests from the renderer (i.e. MediaTomb is running, but your renderer device does not show it) you should try the following settings (the lines below assume that MediaTomb is running on a Linux machine, on network interface eth1):
# route add -net 239.0.0.0 netmask 255.0.0.0 eth1
# ifconfig eth1 allmulti
Those settings will be applied automatically by the init.d startup script.
The init script adds this when you specify an interface in /etc/default/mediatomb. This is where my next problem comes in: It gives me an error saying it cannot find the specified interface. Specifically, eth1. This is the interface my network cable is connected to, and it has an IP address.
I assumed the interface may not have been fully up yet, so I tried to delay the script startup. I'm not sure if I was successful in delaying it, but either way, I still get the error.
I tried specifying the loopback interface "lo" for the init script, and the server starts up without a hitch. Obviously that doesn't help me share files, but maybe it'll help someone point me in the right direction.
Thanks in advance for your help. I can provide any output you may need. You might have to tell me how to get it though.
0
Comments
I am not sure, if I understand you right, but did you edit the init script directly? That is not a good thing. All settings should be made in /etc/default/mediatomb.
Do you get the error messages at boot or when you issue "/etc/init.d/mediatomb start" at the command line?
And I forgot to mention that, sorry. If I run "/etc/init.d/mediatomb start" from the command line, it works fine as well.
When I get home tonight, I'll post my init script and the other related files.
Init script:
#! /bin/sh # # MediaTomb initscript # # Original Author: Tor Krill <tor@excito.com>. # Modified by: Leonhard Wimmer <leo@mediatomb.cc> # # ### BEGIN INIT INFO # Provides: mediatomb # Required-Start: $all # Required-Stop: $all # Should-Start: $all # Should-Stop: $all # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: upnp media server ### END INIT INFO set -e PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DESC="upnp media server" NAME=mediatomb DAEMON=/usr/bin/$NAME PIDFILE=/var/run/$NAME.pid SCRIPTNAME=/etc/init.d/$NAME USER=mediatomb GROUP=mediatomb LOGFILE=/var/log/mediatomb HOME=/user/bryan/mediatomb # Read config file if it is present. if [ -r /etc/default/$NAME ] then . /etc/default/$NAME fi # if NO_START is set, exit gracefully [ "$NO_START" = "yes" ] && exit 0 D_ARGS="-c /etc/mediatomb/config.xml -d -u $USER -g $GROUP -m $HOME -P $PIDFILE -l $LOGFILE" if [ "$INTERFACE" != "" ] ; then D_ARGS="$D_ARGS -e $INTERFACE" fi # Gracefully exit if the package has been removed. test -x $DAEMON || exit 0 # # Function that starts the daemon/service. # d_start() { touch $PIDFILE chown $USER:$GROUP $PIDFILE touch $LOGFILE chown $USER:$GROUP $LOGFILE start-stop-daemon --start --quiet --pidfile $PIDFILE \ --exec $DAEMON -- $D_ARGS $DAEMON_OPTS } # # Function that stops the daemon/service. # d_stop() { start-stop-daemon --stop --signal 2 --retry 5 --quiet --pidfile $PIDFILE \ --name $NAME rm $PIDFILE } # # Function that sends a SIGHUP to the daemon/service. # d_reload() { start-stop-daemon --stop --quiet --pidfile $PIDFILE \ --name $NAME --signal 1 } case "$1" in start) echo -n "Starting $DESC: $NAME" if [ "$INTERFACE" != "" ] ; then # try to add the multicast route /sbin/route add -net 239.0.0.0 netmask 255.0.0.0 $INTERFACE >/dev/null 2>&1 || true fi d_start echo "." ;; stop) echo -n "Stopping $DESC: $NAME" d_stop echo "." ;; reload|force-reload) echo -n "Reloading $DESC configuration..." d_reload echo "done." ;; restart) # # If the "reload" option is implemented, move the "force-reload" # option to the "reload" entry above. If not, "force-reload" is # just the same as "restart". # echo -n "Restarting $DESC: $NAME" d_stop sleep 1 d_start echo "." ;; *) # echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2 echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2 exit 1 ;; esac exit 0And here's the /etc/default/mediatomb text:
And here's a portion of /var/log/mediatomb showing what happens at startup:
Also, just so you don't think I'm using the wrong interface, ifconfig:
eth0 Link encap:Ethernet HWaddr 00:01:29:D1:92:A9 UP BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b) Interrupt:16 Base address:0xe000 eth1 Link encap:Ethernet HWaddr 00:01:29:D1:91:55 inet addr:192.168.0.186 Bcast:192.168.0.255 Mask:255.255.255.0 inet6 addr: fe80::201:29ff:fed1:9155/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:5020421 errors:0 dropped:0 overruns:0 frame:0 TX packets:4621539 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:520555782 (496.4 MB) TX bytes:1097363263 (1.0 GB) Interrupt:20 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)You could check the directories /etc/rc0.d, where the symlink for starting your network should be, and /etc/rc2.d, where i think the mediatomb symlink should be. It looks like S**mediatomb, where ** is a two digit number. The higher the number the later the service gets started in the corresponding runlevel.
"update-rc.d -f mediatomb remove"
"update-rc.d mediatomb defaults 99"
At least you're verifying my actions were correct. Sometimes I feel like a dummy with Linux. Haha.
I know what you mean
But maybe, looking at the error message again, you could add entries in /etc/mediatomb/config.xml for these two errors:
2008-02-06 21:51:29 INFO: Config: option not found: /server/interface using default value:
2008-02-06 21:51:29 INFO: Config: option not found: /server/ip using default value:
Maybe that helps
I started researching udev - networking specifically - and stumbled across another location that is used for naming the interfaces: /etc/network/interfaces. Heh. How obvious is that one?
Anyway, it turns out that file only had a listing for lo. I added eth0 and eth1, so now it looks like:
After rebooting, the server comes up just fine.
//Edit: And as a side not, this is the first result when Googling "mediatomb init." Heh.
Never would have thought about that one, since the devices were shown by ifconfig, so i just figured, they were configured right in /etc/network/interfaces. I guess, since ubuntu uses NetworkManager for configuring network devices, these settings are no longer made during install.
Maybe you should write a mail to the developers, so they could put that into their docs or find a fix for that problem.
Happy streaming ...
sudo update-rc.d -f mediatomb remove
sudo update-rc.d mediatomb defaults 99
sudo gedit /etc/network/interfaces