Ushare - UPnP Media Server for
Western Digital MyBook World Edition

From NAS-Central

GeeXboX uShare homepage: http://ushare.geexbox.org/

Contents

Introduction

uShare is a Upnp (TM) A/V Media Server based on GmediaServer. It implements the server component that provides UPnP media devices with information on available multimedia files. uShare uses the built-in http server of libupnp to stream the files to clients. uShare is written for the GeeXboX project. It is designed to provide access to multimedia contents to GeeXboX but can of course be used by any other UPnP client device. It should compile and run on any modern POSIX compatible system such as Linux. uShare is free software - it is licensed under the terms of the GNU General Public License (GPL).

Supported File Formats List

Supported Devices

Installation

The following UPnP library is required to build and run uShare: Linux SDK for UPnP Devices (libupnp), 1.3.1 or later

Compile from Source

Configure, make and install Portable SDK for UPnP Devices

# wget http://heanet.dl.sourceforge.net/sourceforge/pupnp/libupnp-1.4.6.tar.bz2
# tar -xvjf libupnp-1.4.6.tar.bz2
# cd libupnp-1.4.6
# ./configure
# make 
# make install

Then configure, make and install GeeXboX uShare

# wget http://ushare.geexbox.org/releases/ushare-1.1a.tar.bz2
# tar -xvjf ushare-1.1a.tar.bz2
# cd ushare-1.1a
# ./configure --prefix=/usr/local --sysconfdir=/etc --disable-dlna --disable-nls
# make 
# make install

Now you can try to launch ushare. Type ushare and there might be some errors. I had the following ones:

  1. ushare: can't load library 'libixml.so.2'
  2. ushare: can't load library 'libthreadutil.so.2'
  3. ushare: can't load library 'libupnp.so.2'

Solution:

# ln -s /usr/local/lib/libixml.so.2 /lib/libixml.so.2
# ln -s /usr/local/lib/libthreadutil.so.2 /lib/libthreadutil.so.2
# ln -s /usr/local/lib/libupnp.so.2 /lib/libupnp.so.2

Link all the other possible missing libraries the same way, they are all situated in the /lib/ directory.

To complete the installation, you must edit /etc/ushare.conf to add the location(s) of your media files.

/etc/ushare.conf

I've just changed following lines:
USHARE_PORT=49200
USHARE_OPTIONS=-x

# /etc/ushare.conf
# Configuration file for uShare

# uShare UPnP Friendly Name (default is 'uShare').
USHARE_NAME=

# Interface to listen to (default is eth0).
# Ex : USHARE_IFACE=eth1
USHARE_IFACE=

# Port to listen to (default is random from IANA Dynamic Ports range)
# Ex : USHARE_PORT=49200
USHARE_PORT=49200

# Directories to be shared (space or CSV list).
# Ex: USHARE_DIR=/dir1,/dir2
USHARE_DIR=/shares/internal/PUBLIC/Bart/Media

# Use to override what happens when iconv fails to parse a file name.
# The default uShare behaviour is to not add the entry in the media list
# This option overrides that behaviour and adds the non-iconv'ed string into
# the media list, with the assumption that the renderer will be able to
# handle it. Devices like Noxon 2 have no problem with strings being passed
# as is. (Umlauts for all!)
#
# Options are TRUE/YES/1 for override and anything else for default behaviour
USHARE_OVERRIDE_ICONV_ERR=

# Use XboX 360 compliant profile
USHARE_OPTIONS=-x

Then you can create a start/stop script

/etc/init.d/ushare

I've just changed following line:
DAEMON=/usr/local/bin/ushare

#!/bin/sh
### BEGIN INIT INFO
# Required-Start: $local_fs $syslog
# Required-Stop:
# Default-Start:  2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: start and stop ushare
# Description:
### END INIT INFO

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/local/bin/ushare
NAME=ushare
DESC="uShare UPnP A/V Media Server"
PIDFILE=/var/run/ushare.pid

[ -r "/etc/ushare.conf" ] && . /etc/ushare.conf

# abort if no executable exists
[ -x $DAEMON ] || exit 0

# abort if no shared directory is defined
[ -z "$USHARE_DIR" ] && exit 0

set -e

checkpid() {
  [ -e $PIDFILE ] || touch $PIDFILE
}
case "$1" in
  start)
    echo -n "Starting $DESC: $NAME"
    checkpid
    start-stop-daemon --start --quiet --background --oknodo \
      --make-pidfile --pidfile $PIDFILE \
      --exec $DAEMON -- $USHARE_OPTIONS
    echo "."
  ;;
 stop)
    echo -n "Stopping $DESC: $NAME"
    start-stop-daemon --stop --signal 2 --quiet --oknodo --pidfile $PIDFILE
    echo "."
  ;;
  reload|force-reload)
    echo -n "Reloading $DESC: $NAME"
    start-stop-daemon --stop --signal 1 --quiet --oknodo --pidfile $PIDFILE --e$
    echo "."
  ;;
  reload|force-reload)
    echo -n "Reloading $DESC: $NAME"
    start-stop-daemon --stop --signal 1 --quiet --oknodo --pidfile $PIDFILE --e$
    echo "."
  ;;
  restart)
    $0 stop
    $1 start
  ;;
  *)
    N=/etc/init.d/$NAME
    echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
    exit 2
  ;;
esac

exit 0

Run at Startup

And run the following to have it startup and stop on system start/shutdown.
Give ushare its access rights. Then make a symbolic link to stop the service when the MBWE is shutting down.

# cd /etc/init.d
# chmod 0700 /etc/init.d/ushare
# chown root:root /etc/init.d/ushare
# ln -s /etc/init.d/ushare S99ushare
# ln -s /etc/init.d/ushare K02ushare

The scripts in the directory /etc/init.d/ starting with S[number] are automatically run during system startup with parameter start. The number defines the order the scripts are run. Likewise, scripts starting with K[number] are run when the system is shutting down with parameter stop.

Usage

uShare runs from the console only. It supports the usual --help option which displays usage and option information.

Command Line Options

-n --name=NAME Set UPnP Friendly Name (default is 'uShare')
-i --interface=IFACE Use IFACE Network Interface (default is 'eth0')
-p --port=PORT Forces the HTTP server to run on PORT
-c --content=DIR Share the content of DIR directory (default is './')
-w --no-web Disable the control web page (enabled by default)
-v --verbose Set verbose display.
-D --daemon Run as a daemon.
-V --version Display the version of uShare and exit
-h --help Display this help

uShare expects at least one directory argument (-c argument), specifying where multimedia files are stored. You should probably also use the -i option to specify which interface uShare should listen on.

ushare -i eth0 -c /shares

Web Interface

You can also perform remote control of uShare UPnP Media Server through its web interface. This let you define new content locations at runtime or update the currently shared one in case the filesystem has changed. After starting ushare you can go to the web interface to manage it's shares: http://mybookworld:49200/web/ushare.html

References

  1. GeeXboX uShare : A free UPnP A/V Media Server for Linux.
  2. Ushare - GeeXboX wiki
  3. GeeXboX : the Linux multimedia distribution that uses djmount to provide access to UPnP contents.
  4. SDK for UPnP Devices (libupnp): An Open Source UPnP Development Kit.