Search:  
Gentoo Wiki

HOWTO_Setup_a_UPnP_MediaServer


This article is part of the HOWTO series.
Installation Kernel & Hardware Networks Portage Software System X Server Gaming Non-x86 Emulators Misc
This article shows how to set up a UPnP MediaServer that serves Images, Videos and Audio files to all UPnP enabled clients in the network. There are several programs for the Linux platform. For this HOWTO I'm using uShare.

Contents


Obtaining uShare

Just go to the uShare page and download the source archive. The current version is 0.9.8. When the download is finished, just untar it as usual.

server ~#
wget http://ushare.geexbox.org/releases/ushare-0.9.8.tar.bz2Image:CursorOFF.gif
server ~#
tar xvjf ushare-0.9.8.tar.bz2Image:CursorOFF.gif

Now you should have a new folder called ushare-0.9.8.

Configuring and Compiling

Change into the folder an execute the configure script. When running configure without the --prefix parameter, version 0.9.8 will use the strange value of NONE/etc/ushare.conf as the config file. So we have to force it to use an empty value. Of course, if you like to have it installed in another place, you can adjust the prefix setting accordingly.

server ~#
cd ushare-0.9.8Image:CursorOFF.gif
server ~#
./configure --prefix=Image:CursorOFF.gif

If everything is ok, we can compile and install it.

server ~#
make && make install-stripImage:CursorOFF.gif

Now we have the binary at /bin/ushare and the config file at /etc/ushare.conf however the real work starts now.

Creating a init script

If you try to start uShare by simply typing ushare you will get the following error:

server ~#
ushareImage:CursorOFF.gif

Error: no content directory to be shared.

Why? I don't know, what uShare is looking for, but for sure it's not looking into the config file. So I came up with the idea to write my own init-script. However I still wanted to have the option to change the settings in a config file rather than in the init script itself. So I moved /etc/ushare.conf to /etc/conf.d/ushare. Since this file already has the right syntax, it doesn't need any changes. The only thing left is the init script which looks like this:

File: /etc/init.d/ushare
#!/sbin/runscript

depend() {
  need net
  use syslog
}

start() {
  ebegin "Starting uShare UPnP A/V Media Server"
  PARAMS=""
  if [ -n "$USHARE_NAME" ]; then
    PARAMS="--name=\"$USHARE_NAME\""
  fi
  if [ -n "$USHARE_IFACE" ]; then
    PARAMS="$PARAMS --interface=\"$USHARE_IFACE\""
  fi
  if [ -n "$USHARE_PORT" ]; then
    PARAMS="$PARAMS --port=\"$USHARE_PORT\""
  fi
  if [ -n "$USHARE_DIR" ]; then
    PARAMS="$PARAMS --content=\"$USHARE_DIR\""
  fi
  start-stop-daemon --start --quiet --background --make-pidfile \
  --pidfile /var/run/ushare.pid --exec /bin/ushare \
  -- $PARAMS
  eend $?
}

stop() {
  ebegin "Stopping uShare UPnP A/V Media Server"
  start-stop-daemon --stop -quiet --pidfile /var/run/ushare.pid
  eend $?
}

That's it.

Start the MediaServer at system startup

Just type

server ~#
rc-update add ushare defaultImage:CursorOFF.gif

and you're done. As soon as you start your computer, the UPnP MediaServer will start to serve the media files.

Retrieved from "http://www.gentoo-wiki.info/HOWTO_Setup_a_UPnP_MediaServer"

Last modified: Thu, 04 Sep 2008 01:37:00 +0000 Hits: 1,642