]> git.sur5r.net Git - bacula/bacula/blob - bacula/scripts/breload.in
958acad082036cdd9016436321cb0cf300115aa7
[bacula/bacula] / bacula / scripts / breload.in
1 #! /bin/sh
2 #
3 #   Bacula(R) - The Network Backup Solution
4 #
5 #   Copyright (C) 2000-2015 Kern Sibbald
6 #
7 #   The original author of Bacula is Kern Sibbald, with contributions
8 #   from many others, a complete list can be found in the file AUTHORS.
9 #
10 #   You may use this file and others of this release according to the
11 #   license defined in the LICENSE file, which includes the Affero General
12 #   Public License, v3.0 ("AGPLv3") and some additional permissions and
13 #   terms pursuant to its AGPLv3 Section 7.
14 #
15 #   This notice must be preserved when any source code is 
16 #   conveyed and/or propagated.
17 #
18 #   Bacula(R) is a registered trademark of Kern Sibbald.
19 #
20 # breload This shell script takes care of reloading the director after
21 #         a backup of the configuration and a bacula-dir -t test
22 #
23 #
24
25 BACDIRBIN=@sbindir@
26 BACDIRCFG=@sysconfdir@
27 BACWORKDIR=@working_dir@
28 BACBKPDIR=$BACWORKDIR/bkp
29 Bacula="@BACULA@"
30 DIR_USER=@dir_user@
31 RET=0
32
33 if [ -x ${BACDIRBIN}/bacula-dir -a -r ${BACDIRCFG}/bacula-dir.conf ]; then
34   echo "Testing the $Bacula Director daemon configuration"
35
36   if [ $(whoami) != "$DIR_USER" ]; then
37       USER_OPT="-u $DIR_USER"
38   fi
39
40   ${BACDIRBIN}/bacula-dir -t $USER_OPT -c ${BACDIRCFG}/bacula-dir.conf
41
42   RET=$?
43   if [ $RET = 0 ]; then
44       if [ ! -d $BACBKPDIR ]; then
45          echo "Creating Backup configuration directory"
46          mkdir -p $BACBKPDIR 
47          chmod 700 $BACBKPDIR
48          chown $DIR_USER $BACBKPDIR
49       fi
50       if [ -d $BACDIRCFG/conf.d ]; then
51           CONFD=$BACDIRCFG/conf.d
52       fi
53       if [ -d $BACBKPDIR ]; then
54         echo "Backup configuration"
55         tar cfz $BACBKPDIR/bacula-dir-conf.$(date +%s).tgz $BACDIRCFG/*conf $CONFD
56       fi
57       echo reload | ${BACDIRBIN}/bconsole >/dev/null
58       echo "Reloading configuration"
59   else
60       echo "Can't reload configuration, please correct errors first"
61   fi
62 fi 
63 exit $RET