3 # Run a simple backup of the Bacula build directory
6 TestName="source-addr-test"
14 # Zap out any schedule in default conf file so that
15 # it doesn't start during our test
18 echo "s% Schedule =%# Schedule =%g" >${outf}
19 cp $scripts/bacula-dir.conf $tmp/1
20 sed -f ${outf} $tmp/1 >$scripts/bacula-dir.conf
22 PATH=$PATH:/sbin:/usr/sbin
24 # Deduce a primary IP address by examining
25 # the interface defined by INTERFACE=
28 if [ $os = 'FreeBSD' ]; then
30 IP=`ifconfig ${INTERFACE} | perl -ne '/inet (.+?) / && print $1'`
31 elif [ $os = 'Linux' ]; then
33 IP=`ifconfig ${INTERFACE} | perl -ne '/inet addr:(.+?) / && print $1'`
36 if [ "$IP" = '' ]; then
37 echo "Can't detect ip address"
42 echo "s/PidDirectory/DirSourceAddress=$IP; PidDirectory/g" > $outf
43 echo "s/Address =/Address = 127.0.0.1 #/g" >> $outf
44 cp $scripts/bacula-dir.conf $tmp/1
45 sed -f ${outf} ${cwd}/tmp/1 > $scripts/bacula-dir.conf
47 # Set source address on the FD as well
48 echo "s/Pid Directory/FDSourceAddress=$IP; Pid Directory/g" >$outf
49 cp $scripts/bacula-fd.conf $tmp/2
50 sed -f ${outf} ${cwd}/tmp/2 > $scripts/bacula-fd.conf
53 FDPORT=$(($BASEPORT + 1))
54 SDPORT=$(($BASEPORT + 2))
56 change_jobname BackupClient1 $JobName
59 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
62 @$out ${cwd}/tmp/log1.out
63 @#label volume=TestVolume001 storage=File pool=File
64 @#setdebug level=100 storage=File
74 print_debug "Detecting connections to SD sourced from ${IP}"
75 netstat -tan | grep -E "127.0.0.1(.|:)$SDPORT .* ${IP}" > $tmp/log3.out
78 print_debug "Couldn't detect a connection to the SD sourced from SourceAddress ${IP}"
81 print_debug "and connections to FD sourced from ${IP}"
82 netstat -tan | grep -E "127.0.0.1(.|:)$FDPORT .* ${IP}" >> $tmp/log3.out
85 print_debug "Couldn't detect a connection to the FD sourced from SourceAddress ${IP}"
88 if [ "$stat" = 2 ] ; then
92 if [ "$debug" = 1 ] ; then
96 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
99 @$out ${cwd}/tmp/log1.out
100 label volume=TestVolume001 storage=File pool=File
101 @#setdebug level=100 storage=File
107 @$out ${cwd}/tmp/log2.out
108 restore where=${cwd}/tmp/bacula-restores select all done
116 check_for_zombie_jobs storage=File
121 if [ "$stat" = 2 ]; then
122 print_debug `cat $tmp/log3.out`