#!/bin/sh
#
# Copyright (C) 2000-2022 Kern Sibbald
# License: BSD 2-Clause; see file LICENSE-FOSS
#

#
#  Test if daemons start
#

TestName="pretest"
JobName=backup
error=0

. scripts/functions

copy_test_confs


cat <<END_OF_DATA >${cwd}/tmp/bconcmds
messages
quit
END_OF_DATA

start_test

run_bacula
if [ $? -ne 0 ]; then
   echo "Error: Starting Bacula Failed in pretest"
   make distclean
   make setup
   exit 1
fi

bin/bacula-ctl-dir status >/dev/null
if [ $? -ne 0 ]; then
   echo "Error: bacula-dir failed to start"
   make distclean
   make setup
   exit 1
fi

bin/bacula-ctl-fd status >/dev/null
if [ $? -ne 0 ]; then
   echo "Error: bacula-fd failed to start"
   make distclean
   make setup
   exit 1
fi

bin/bacula-ctl-sd status >/dev/null
if [ $? -ne 0 ]; then
   echo "Error: bacula-sd failed to start"
   make distclean
   make setup
   exit 1
fi

stop_bacula

dstat=0
bstat=$error
rstat=0
export dstat
export bstat
export rstat

end_test

exit $error
