#!/bin/sh
# distribution boxbackup-0.11.1 (svn version: 2821_2827)
# Box Backup, http://www.boxbackup.org/
# 
# Copyright (c) 2003-2010, Ben Summers and contributors.
# All rights reserved.
# 
# Note that this project uses mixed licensing. Any file with this license
# attached, or where the code LICENSE-GPL appears on the first line, falls
# under the "Box Backup GPL" license. See the file COPYING.txt for more
# information about this license.
# 
# ---------------------------------------------------------------------
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
# 
# [http://www.gnu.org/licenses/old-licenses/gpl-2.0.html#SEC4]
# 
# As a special exception to the GPLv2, the Box Backup Project gives
# permission to link any code falling under this license (the Box Backup
# GPL) with any software that can be downloaded from
# the OpenSSL website [http://www.openssl.org] under either the
# "OpenSSL License" or the "Original SSLeay License", and to distribute
# the linked executables under the terms of the "Box Backup GPL" license.
# 
# As a special exception to the GPLv2, the Box Backup Project gives
# permission to link any code falling under this license (the Box Backup
# GPL) with any version of Microsoft's Volume Shadow Copy Service 7.2 SDK
# or Microsoft Windows Software Development Kit (SDK), including
# vssapi.lib, that can be downloaded from the Microsoft website
# [*.microsoft.com], and to distribute the linked executables under the
# terms of the "Box Backup GPL" license.
#
# Copyright (c)2004, Nothing But Net Limited
#   <chris.smith@nothingbutnet.co.nz>
#
######################################################################
# RELEASED AND PROVIDED TO YOU UNDER THE SAME LICENCE AS THE BOXBACKUP
# SUITE OF PROGRAMS. LICENCE MAY BE VIEWED HERE:
#
# http://www.boxbackup.org/license.html
######################################################################
#
# /etc/init.d/bbstored
#   and its symbolic link
# /(usr/)sbin/rcbbstored
#
### BEGIN INIT INFO
# Provides:          bbstored
# Required-Start:    $named $network $local_fs $syslog
# X-UnitedLinux-Should-Start: $time ypbind sendmail
# Required-Stop:     $named $network $localfs $syslog
# X-UnitedLinux-Should-Stop: $time ypbind sendmail
# Default-Start:     3 5
# Default-Stop:      0 1 2 6
# Short-Description: BoxBackup server side daemon
# Description: Server daemon for the BoxBackup software,
#	to which bbackupd clients connect.
### END INIT INFO
# 

# Check for missing binaries (stale symlinks should not happen)
BBSTORED_BIN=/usr/local/sbin/bbstored
if [ ! -x $BBSTORED_BIN ] ; then
	echo "$BBSTORED_BIN not installed"
	exit 5
fi

. /etc/rc.status

# Reset status of this service
rc_reset

case "$1" in
	start)
	echo -n "Starting bbstored "
	startproc $BBSTORED_BIN
	rc_status -v
	;;

    stop)
	echo -n "Shutting down bbstored "
	killproc -TERM $BBSTORED_BIN
	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
	rc_status
	;;

    restart)
	$0 stop
	$0 start
	rc_status
	;;

    force-reload)
	echo -n "Reload service bbstored "
	killproc -HUP $BBSTORED_BIN
	rc_status -v
	;;

    reload)
	echo -n "Reload service bbstored  "
	killproc -HUP $BBSTORED_BIN
	rc_status -v
	;;

    status)
	echo -n "Checking for service bbstored "
	checkproc $BBSTORED_BIN
	rc_status -v
	;;

    probe)
	test /etc/box/bbstored.conf \
		-nt /var/run/bbstored.pid && echo reload
	;;

    *)
	echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"
	exit 1
	;;

esac
rc_exit
