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