9 · 07

Ushare on Gentoo Linux

Ushare is a UPnP media server on linux. I use it to browse media files from my Xbox. There is no official gentoo ebuild. Sunrise Gentoo overlay provides an ebuild for Ushare, it requires some modifications to be used. I noticed some problems:
  1. Ushare daemon is configured to run as root. Without being paranoid, I don't want to entrust a root daemon which manipulate my precious media directory.
  2. Boot script in init.d directory is written for debian, so it does not work at all on Gentoo.
  3. Default configuration file contains some wrong variable names. So this configuration directives are ignored.
I rewrote the init.d script to work on Gentoo and to launch ushare daemon as nobody user. To sum up, Ushare can be deployed rapidly as follow: 1. Checkout Sunrise overlay with layman
emerge -v layman
layman -a sunrise
echo source /usr/portage/local/layman/make.conf >> /etc/make.conf
echo media-video/ushare >> /etc/portage/package.keywords
emerge -v ushare
2. Replace the Ushare boot script /etc/init.d/ushare by my script:
#!/sbin/runscript
#- by shad
DAEMON="/usr/bin/ushare"
NAME="ushare"
CONFIGFILE="/etc/ushare.conf"
OPTS="-f $CONFIGFILE"
PIDFILE="/var/run/ushare.pid"
USER="nobody"
[ -x $DAEMON ] || exit 0
start() {
ebegin "Starting $NAME"
start-stop-daemon --start --quiet --background --pidfile $PIDFILE \
--make-pidfile --exec /bin/su -- --command "$DAEMON $OPTS" $USER
eend $?
}
stop() {
ebegin "Stopping $NAME"
start-stop-daemon --stop --quiet --pidfile $PIDFILE
eend $?
}
3. The last thing to check is the name of configuration variables in /etc/ushare.conf. Make sure each variable starts with the "USHARE_" prefix.
Then,
/etc/init.d/ushare start
and watch your favorite movie on your Xbox 360 :)