3 # Copyright (C) 2000-2015 Kern Sibbald
4 # License: BSD 2-Clause; see file LICENSE-FOSS
8 # Run a simple backup of the Bacula build directory
11 TestName="source-addr-test"
19 # Zap out any schedule in default conf file so that
20 # it doesn't start during our test
23 echo "s% Schedule =%# Schedule =%g" >${outf}
24 cp $scripts/bacula-dir.conf $tmp/1
25 sed -f ${outf} $tmp/1 >$scripts/bacula-dir.conf
27 PATH=$PATH:/sbin:/usr/sbin
29 # Deduce a primary IP address by examining
30 # the interface defined by INTERFACE=
34 if [ $os = 'FreeBSD' ]; then
36 IP=`ifconfig ${INTERFACE} | perl -ne '/inet (.+?) / && print $1'`
37 elif [ $os = 'Linux' ]; then
40 IP=`ifconfig ${INTERFACE} | perl -ne '/inet (addr:)?(.+?) / && print $2'`
43 if [ "$IP" = '' ]; then
44 echo "Can't detect ip address"
49 echo "s/PidDirectory/DirSourceAddress=$IP; PidDirectory/g" > $outf
50 echo "s/Address =/Address = \"127.0.0.1\" #/g" >> $outf
51 cp $scripts/bacula-dir.conf $tmp/1
52 sed -f ${outf} ${cwd}/tmp/1 > $scripts/bacula-dir.conf
54 # Set source address on the FD as well
55 echo "s/Pid Directory/FDSourceAddress=$IP; Pid Directory/g" >$outf
56 cp $scripts/bacula-fd.conf $tmp/2
57 sed -f ${outf} ${cwd}/tmp/2 > $scripts/bacula-fd.conf
60 FDPORT=$(($BASEPORT + 1))
61 SDPORT=$(($BASEPORT + 2))
63 change_jobname BackupClient1 $JobName
66 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
69 @$out ${cwd}/tmp/log1.out
70 @#label volume=TestVolume001 storage=File1 pool=File slot=1 drive=0
71 @#setdebug level=100 storage=File1
72 setbandwidth client limit=1000
82 print_debug "Detecting connections to SD sourced from ${IP}"
83 netstat -tan | grep -E "127\.0\.0\.1(.|:)$SDPORT .* ${IP}" > $tmp/log3.out
86 print_debug "Couldn't detect a connection to the SD sourced from SourceAddress ${IP}"
89 print_debug "and connections to FD sourced from ${IP}"
90 netstat -tan | grep -E "127\.0\.0\.1(.|:)$FDPORT .* ${IP}" >> $tmp/log3.out
93 print_debug "Couldn't detect a connection to the FD sourced from SourceAddress ${IP}"
96 if [ "$stat" = 2 ] ; then
100 if [ "$debug" = 1 ] ; then
104 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
106 setbandwidth client limit=1000000
112 @$out ${cwd}/tmp/log2.out
113 restore where=${cwd}/tmp/bacula-restores select all done
121 check_for_zombie_jobs storage=File1
126 if [ "$stat" = 2 ]; then
127 print_debug `cat $tmp/log3.out`