3 # Test if Bacula can automatically create a Volume label.
6 TestName="runscript-test"
13 rm -f bin/bacula-dir.conf
15 /bin/cp -f scripts/bacula-dir.conf.testrunscript bin/bacula-dir.conf
17 echo "${cwd}/build/po" >/tmp/file-list
21 cat <<END_OF_DATA >tmp/bconcmds
24 label volume=TestVolume001
25 @$out tmp/RUN_FD_WARNING.log
26 run job=RUN_FD_WARNING yes
30 @$out tmp/RUN_ALL_OK.log
31 run job=RUN_ALL_OK yes
35 @$out tmp/RUN_FD_FAILED.log
36 run job=RUN_FD_FAILED yes
40 @$out tmp/RUN_DIR_FAILED.log
41 run job=RUN_DIR_FAILED yes
45 @$out tmp/RUN_FD_FAILED2.log
46 run job=RUN_FD_FAILED2 yes
55 cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf > /dev/null
62 if grep -q 'dir: BeforeJob: run command "/bin/echo RunBeforeJob"' tmp/RUN_ALL_OK.log &&
63 grep -q 'fd: ClientRunBeforeJob: ClientRunBeforeJob' tmp/RUN_ALL_OK.log &&
64 grep -q 'fd: ClientAfterJob: run command "/bin/echo ClientRunAfterJob' tmp/RUN_ALL_OK.log &&
65 grep -q 'dir: AfterJob: run command "/bin/echo RunAfterJob' tmp/RUN_ALL_OK.log
67 [ "$debug" = 1 ] && echo RUN_ALL_OK ok
69 echo "RUN_ALL_OK in error"
73 if grep -q 'dir: BeforeJob: run command "/bin/false RUN_DIR_FAILED"' tmp/RUN_DIR_FAILED.log &&
74 grep -q 'dir: AfterJob: RunAfterFailedJob' tmp/RUN_DIR_FAILED.log &&
75 true # grep -q 'Backup OK -- with warnings' tmp/RUN_DIR_FAILED.log
77 [ "$debug" = 1 ] && echo RUN_DIR_FAILED ok
79 echo "RUN_DIR_FAILED in error"
83 if grep -q 'fd: ClientBeforeJob: run command "/bin/false RUN_FD_FAILED1"' tmp/RUN_FD_FAILED.log &&
84 grep -q 'fd: ClientBeforeJob: run command "/bin/false RUN_FD_FAILED2"' tmp/RUN_FD_FAILED.log &&
85 grep -q 'dir: AfterJob: run command "/bin/echo RunAfterFailedJob"' tmp/RUN_FD_FAILED.log &&
86 grep -q '*** Backup Error ***' tmp/RUN_FD_FAILED.log
88 [ "$debug" = 1 ] && echo RUN_FD_FAILED ok
90 echo "RUN_FD_FAILED in error"
94 if grep -q 'fd: ClientBeforeJob: run command "/bin/false RUN_FD_FAILED1"' tmp/RUN_FD_FAILED2.log &&
95 ! grep -q 'fd: ClientBeforeJob: run command "/bin/false RUN_FD_FAILED2"' tmp/RUN_FD_FAILED2.log &&
96 grep -q 'fd: ClientBeforeJob: run command "/bin/false RUN_FD_FAILED3"' tmp/RUN_FD_FAILED2.log &&
97 grep -q 'dir: AfterJob: run command "/bin/echo RunAfterFailedJob"' tmp/RUN_FD_FAILED2.log &&
98 grep -q '*** Backup Error ***' tmp/RUN_FD_FAILED2.log
101 [ "$debug" = 1 ] && echo RUN_FD_FAILED ok
103 echo "RUN_FD_FAILED2 in error"
107 if grep -q 'fd: ClientBeforeJob: run command "/bin/false RUN_FD_WARNING"' tmp/RUN_FD_WARNING.log &&
108 ! grep -q 'RunAfterFailedJob' tmp/RUN_FD_WARNING.log &&
109 grep -q 'Backup OK -- with warnings' tmp/RUN_FD_WARNING.log
111 [ "$debug" = 1 ] && echo RUN_FD_WARNING ok
113 echo "RUN_FD_WARNING in error"