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