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

Vuse init.d Control Script

Vuse (Azureus) is a bit torrent client.

This init.d script allows the user to stop/start the application on boot, but can also start a process where it launches every so often to make sure that the application is running.

/etc/init.d/vuse
#!/usr/bin/env bash
##############################################################################
#                                                                            #
# Vuse (projects@brandt.ie)                                                  #
#                                                                            #
# This script launches the Vuse BitTorrent Client on boot.                   #
#                                                                            #
##############################################################################
#
### BEGIN INIT INFO
# Provides:          Vuse
# 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: Vuse BitTorrent Client. 
# Description:       Vuse BitTorrent Client
### END INIT INFO

# Check for existence of the rc script
RCSCRIPT=/usr/bin/rcvuse
test -x $RCSCRIPT || ln -fs /etc/init.d/vuse $RCSCRIPT

# Check for existence of needed binary file
VUSE_BIN=/opt/azureus/azureus
test -r $VUSE_BIN || { echo "$VUSE_BIN not existing";
	if [ "$1" = "stop" ]; then exit 0;
	else exit 5; fi; }

VUSE_USER=bob
id $VUSE_USER > /dev/null 2> /dev/null || { echo "$VUSE_USER user doesn't exist";
	if [ "$1" = "stop" ]; then exit 0;
	else exit 4; fi; }
USER_PARAM=
[ `id -u` == 0 ] && USER_PARAM="-u $VUSE_USER "

VUSE_OPTIONS=''
VUSE_MONITOR_TIMEOUT=2h

. /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 Vuse "
	/sbin/startproc $USER_PARAM$VUSE_BIN $VUSE_OPTIONS

	# Remember status and be verbose
	rc_status -v
	;;
    stop)
	echo -n "Shutting down Vuse "
	/sbin/killproc -TERM $VUSE_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 Vuse "
	/sbin/checkproc $VUSE_BIN
	# Remember status and be verbose
	rc_status -v
	;;
    monitor)
	echo "Starting Monitoring of the Vuse service. Timeout = $VUSE_MONITOR_TIMEOUT"
	$0 start-sleep

	# Remember status and be quiet
	rc_status
	;;	
    start-sleep)
	echo "Starting Monitoring of the Vuse service. Timeout = $VUSE_MONITOR_TIMEOUT"

	if ! $0 status ; then
		$0 start
		sleep $VUSE_MONITOR_TIMEOUT && $0 start-sleep &
	fi

	# Remember status and be quiet
	rc_status
	;;
    *)
	echo "Usage: $0 {start|stop|status|try-restart|restart|monitor)"
	exit 1
	;;
esac
rc_exit
Edit - History - Print - Recent Changes - Search
Page last modified on February 13, 2010, at 06:51 PM