Recent Changes - Search:

Bob Brandt

Linux Projects


Server Projects

Desktop Projects

Novell Projects


VMware Projects


N900 (Maemo) Projects


Python Projects


OpenOffice.org Projects


Other Projects


PmWiki

edit SideBar

uShare init.d Control Script

Other.UShare History

Hide minor edits - Show changes to markup

February 13, 2010, at 06:19 PM by 217.75.11.41 -
Deleted lines 81-83:
	[ -e $USHARE_PID ] || touch $USHARE_PID
Deleted lines 88-90:
	## Stop daemon with killproc(8) and if this fails
	## killproc sets the return value according to LSB.
Deleted lines 94-96:
	## Do a restart only if the service was active before.
	## Note: try-restart is now part of LSB (as of 1.9).
	## RH has a similar command named condrestart.
Deleted lines 117-118:
	## Check status with checkproc(8), if process is running
	## checkproc will return with exit status 0.
February 13, 2010, at 06:10 PM by 217.75.11.41 -
Changed lines 58-59 from:

USHARE_OPTIONS='--content="/media/downloads/Torrent Incomplete" -D'

to:

USHARE_OPTIONS='-D'

February 13, 2010, at 06:08 PM by 217.75.11.41 -
Added lines 5-6:

uShare does come with it's own init.d script. But it just wasn't what I needed. So I made my own.

February 13, 2010, at 06:07 PM by 217.75.11.41 -
Changed lines 19-22 from:
  1. Required-Start: $network
  2. Should-Start: $network
  3. Required-Stop: $network
  4. Should-Stop: network
to:
  1. Required-Start: $local_fs $remote_fs $syslog $network
  2. Should-Start:
  3. Required-Stop: $local_fs $remote_fs $syslog $network
  4. Should-Stop:
Changed lines 56-57 from:

USHARE_ARGS='-D'

to:

USHARE_OPTIONS='--content="/media/downloads/Torrent Incomplete" -D'

Changed lines 80-83 from:
	## Start daemon with startproc(8). If this fails
	## the return value is set appropriately by startproc.
	/sbin/startproc $USER_PARAM$USHARE_BIN $USHARE_ARGS
to:
	[ -e $USHARE_PID ] || touch $USHARE_PID

	/sbin/startproc $USER_PARAM$USHARE_BIN $USHARE_OPTIONS
February 13, 2010, at 05:26 PM by 217.75.11.41 -
Added lines 1-140:

(:title uShare init.d Control Script:)

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.

/etc/init.d/uShare

(:div style="border-style:ridge; border-width:2px; background-color:#ffffcc; margin-left:50px; overflow:auto; width:650px; height:500px;":)

#!/usr/bin/env bash
##############################################################################
#                                                                            #
# uShare (projects@brandt.ie)                                                #
#                                                                            #
# This script launches the uShare UPnP on boot.                              #
#                                                                            #
##############################################################################
#
### BEGIN INIT INFO
# Provides:          uShare
# Required-Start:    $network
# Should-Start:      $network
# Required-Stop:     $network
# Should-Stop:       network
# 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_ARGS='-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 "
	## Start daemon with startproc(8). If this fails
	## the return value is set appropriately by startproc.
	/sbin/startproc $USER_PARAM$USHARE_BIN $USHARE_ARGS

	# Remember status and be verbose
	rc_status -v
	;;
    stop)
	echo -n "Shutting down uShare "
	## Stop daemon with killproc(8) and if this fails
	## killproc sets the return value according to LSB.

	/sbin/killproc -TERM $USHARE_BIN

	# Remember status and be verbose
	rc_status -v
	;;
    try-restart|condrestart)
	## Do a restart only if the service was active before.
	## Note: try-restart is now part of LSB (as of 1.9).
	## RH has a similar command named 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 "
	## Check status with checkproc(8), if process is running
	## checkproc will return with exit status 0.
	/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

(:divend:)

References:

  • http://ushare.geexbox.org/
Edit - History - Print - Recent Changes - Search
Page last modified on February 13, 2010, at 06:19 PM