afedbd3
#!/bin/bash
afedbd3
#
afedbd3
# bacula-fd     This shell script takes care of starting and stopping
afedbd3
#               the bacula-fd daemon, the backup client enabling bacula
afedbd3
#               to backup the local machine.
afedbd3
#
afedbd3
# chkconfig: - 80 20
afedbd3
# description: Bacula-fd is a Backup-client, which is the program \
afedbd3
#              that enables the bacula-server to backup the local \
afedbd3
#              machine.
afedbd3
# processname: bacula-fd
afedbd3
# config: /etc/bacula/bacula-fd.conf
afedbd3
# pidfile: /var/run/bacula-fd.9102.pid
afedbd3
afedbd3
# Source function library.
afedbd3
. /etc/init.d/functions
afedbd3
afedbd3
# Source configuration.
afedbd3
if [ -f /etc/sysconfig/bacula-fd ] ; then
afedbd3
        . /etc/sysconfig/bacula-fd
afedbd3
fi
afedbd3
afedbd3
RETVAL=0
afedbd3
prog="bacula-fd"
afedbd3
CONFIG="/etc/bacula/bacula-fd.conf"
afedbd3
OPTS="-c $CONFIG"
afedbd3
afedbd3
checkconf() {
afedbd3
	# Check if we still have our @@PLACEHOLDERS@@ in the config.
afedbd3
	# If yes, refuse to start, the user has never touched the config.
afedbd3
	grep -q '_PASSWORD@@' $CONFIG
afedbd3
	if [ $? -eq 0 ]; then
afedbd3
		echo -n "Error: Not been configured"
afedbd3
		echo_failure
afedbd3
		echo
afedbd3
		exit 1
afedbd3
	fi
afedbd3
}
afedbd3
afedbd3
afedbd3
start() {
afedbd3
	echo -n "Starting $prog: "
afedbd3
	checkconf
afedbd3
	daemon $prog $OPTS
afedbd3
	RETVAL=$?
afedbd3
	echo
afedbd3
	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
afedbd3
	return $RETVAL
afedbd3
}	
afedbd3
afedbd3
stop() {
afedbd3
	echo -n "Shutting down $prog: "
afedbd3
	killproc $prog
afedbd3
	RETVAL=$?
afedbd3
	echo
afedbd3
	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
afedbd3
	return $RETVAL
afedbd3
}
afedbd3
afedbd3
case "$1" in
afedbd3
    start)
afedbd3
		start
afedbd3
		;;
afedbd3
    stop)
afedbd3
		stop
afedbd3
		;;
afedbd3
    status)
afedbd3
		status $prog
afedbd3
		;;
afedbd3
    restart)
afedbd3
    	stop
afedbd3
		start
afedbd3
		RETVAL=$?
afedbd3
		;;
afedbd3
    reload)
afedbd3
		;;
afedbd3
    condrestart)
afedbd3
		if [ -f /var/lock/subsys/$prog ]; then
afedbd3
			stop
afedbd3
			start
afedbd3
			RETVAL=$?
afedbd3
		fi
afedbd3
		;;
afedbd3
    *)
afedbd3
	echo "Usage: $prog {start|stop|status|reload|restart}"
afedbd3
	exit 1
afedbd3
	;;
afedbd3
esac
afedbd3
exit $?