uShare is a UPnP (TM) A/V & DLNA Media Server. 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 does come with it's own init.d script. But it just wasn't what I needed. So I made my own.
#!/usr/bin/env bash
##############################################################################
# #
# uShare (projects@brandt.ie) #
# #
# This script launches the uShare UPnP on boot. #
# #
##############################################################################
#
### BEGIN INIT INFO
# Provides: uShare
# Required-Start: $local_fs $remote_fs $syslog $network
# Should-Start:
# Required-Stop: $local_fs $remote_fs $syslog $network
# Should-Stop:
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Short-Description: uShare daemon providing a UPnP A/V & DLNA Media Server.
# Description: uShare is a UPnP (TM) A/V & DLNA Media Server.
# 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.
### END INIT INFO
# Check for existence of the rc script
RCSCRIPT=/usr/bin/rcuShare
test -x $RCSCRIPT || ln -fs /etc/init.d/uShare $RCSCRIPT
# Check for existence of needed binary file
USHARE_BIN=/usr/bin/ushare
test -r $USHARE_BIN || { echo "$USHARE_BIN not existing";
if [ "$1" = "stop" ]; then exit 0;
else exit 5; fi; }
# Check for existence of needed config file
USHARE_CONFIG=/etc/ushare.conf
test -r $USHARE_CONFIG || { echo "$USHARE_CONFIG not existing";
if [ "$1" = "stop" ]; then exit 0;
else exit 6; fi; }
USHARE_USER=bob
id $USHARE_USER > /dev/null 2> /dev/null || { echo "$USHARE_USER user doesn't exist";
if [ "$1" = "stop" ]; then exit 0;
else exit 4; fi; }
USER_PARAM=
[ `id -u` == 0 ] && USER_PARAM="-u $USHARE_USER "
USHARE_OPTIONS='-D'
. /etc/rc.status
rc_reset
# Return values acc. to LSB for all commands but status:
# 0 - success
# 1 - generic or unspecified error
# 2 - invalid or excess argument(s)
# 3 - unimplemented feature (e.g. "reload")
# 4 - user had insufficient privileges
# 5 - program is not installed
# 6 - program is not configured
# 7 - program is not running
# 8--199 - reserved (8--99 LSB, 100--149 distrib, 150--199 appl)
#
# Note that starting an already running service, stopping
# or restarting a not-running service as well as the restart
# with force-reload (in case signaling is not supported) are
# considered a success.
case "$1" in
start)
echo -n "Starting uShare "
/sbin/startproc $USER_PARAM$USHARE_BIN $USHARE_OPTIONS
# Remember status and be verbose
rc_status -v
;;
stop)
echo -n "Shutting down uShare "
/sbin/killproc -TERM $USHARE_BIN
# Remember status and be verbose
rc_status -v
;;
try-restart|condrestart)
if test "$1" = "condrestart"; then
echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}"
fi
$0 status
if test $? = 0; then
$0 restart
else
rc_reset # Not running is not a failure.
fi
# Remember status and be quiet
rc_status
;;
restart)
## Stop the service and regardless of whether it was
## running or not, start it again.
$0 stop
$0 start
# Remember status and be quiet
rc_status
;;
status)
echo -n "Checking for service uShare "
/sbin/checkproc $USHARE_BIN
# Remember status and be verbose
rc_status -v
;;
*)
echo "Usage: $0 {start|stop|status|try-restart|restart)"
exit 1
;;
esac
rc_exit
References: