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