Blob Blame History Raw
#!/bin/bash
#
# bacula2-fd    This shell script takes care of starting and stopping
#               the bacula2-fd daemon, the backup client enabling bacula
#               to backup the local machine.
#
# chkconfig: - 80 20
# description: bacula2-fd is a Backup-client, which is the program \
#              that enables the bacula-server to backup the local \
#              machine.
# processname: bacula2-fd
# config: /etc/bacula2/bacula-fd.conf
# pidfile: /var/run/bacula2-fd.9102.pid

# Source function library.
. /etc/init.d/functions

# Source configuration.
if [ -f /etc/sysconfig/bacula2-fd ] ; then
        . /etc/sysconfig/bacula2-fd
fi

RETVAL=0
prog="bacula2-fd"
CONFIG="/etc/bacula2/bacula-fd.conf"
OPTS="-c $CONFIG"

checkconf() {
	# Check if we still have our @@PLACEHOLDERS@@ in the config.
	# If yes, refuse to start, the user has never touched the config.
	grep -q '_PASSWORD@@' $CONFIG
	if [ $? -eq 0 ]; then
		echo -n "Error: Not been configured"
		echo_failure
		echo
		exit 1
	fi
}


start() {
	echo -n "Starting $prog: "
	checkconf
	daemon $prog $OPTS
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
	return $RETVAL
}	

stop() {
	echo -n "Shutting down $prog: "
	killproc $prog
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
	return $RETVAL
}

case "$1" in
    start)
		start
		;;
    stop)
		stop
		;;
    status)
		status $prog
		;;
    restart)
    	stop
		start
		RETVAL=$?
		;;
    reload)
		;;
    condrestart)
		if [ -f /var/lock/subsys/$prog ]; then
			stop
			start
			RETVAL=$?
		fi
		;;
    *)
	echo "Usage: $prog {start|stop|status|reload|restart}"
	exit 1
	;;
esac
exit $?