Help with a bash script to proceed if bundle id is found
mdfind does not produce an unsuccessful exit code but you could pipe the results to grep which does. The code would look something like this:

mdfind "kMDItemCFBundleIdentifier = com.apple.Terminal" | grep -q Terminal || installer ....


|| is logical or.

It could also be written

if mdfind "kMDItemCFBundleIdentifier = com.apple.Terminal" | grep -q Terminal
then
  :
else
  installer ...
fi