Skip to main content
Answer

Tried to be sneaky.. but failed.

  • May 6, 2013
  • 4 replies
  • 7 views

ImAMacGuy
Forum|alt.badge.img+23

I tried to adapt the script from https://jamfnation.jamfsoftware.com/discussion.html?id=6630 and I got it 1/2 working... but it always returns back that the file is not there, even though I can ssh into the test box and see that it is... Could someone point out where the logic is wrong?

#!/bin/bash
#
# looks for the FVMaster keychain.
files=('FileVaultMaster.keychain')
subdirs=('/Library/Keychains')
FVMaster" "

for d in ${subdirs[@]}; do
   for f in ${files[@]]}; do 
      if [ ! -z `find $d -maxdepth 1 -name $f` ]; then
         FVMaster=1
      fi
   done    
done


if [ $FVMaster]; then
   echo "<result>FileVaultMaster detected</result>"
else
   echo "<result>FileVaultMaster Not found</result>"
fi

Best answer by stevewood

Fat fingers....looks like an extra ] in the second for statement:

for f in ${files[@]]}; do

Try this instead:

for f in ${files[@]}; do

4 replies

stevewood
Forum|alt.badge.img+38
  • Hall of Fame
  • Answer
  • May 6, 2013

Fat fingers....looks like an extra ] in the second for statement:

for f in ${files[@]]}; do

Try this instead:

for f in ${files[@]}; do

Forum|alt.badge.img+13
  • Valued Contributor
  • May 6, 2013

I think there's a bit more flourish here than I like in my scripts, and it doesn't help you much. If you're putting the file in a specific location, look for it there. Searching for it leads to problems.

#!/bin/bash

if [ -e /Library/Keychains/FileVaultMaster.keychain ]; then
   echo "<result>FileVaultMaster detected</result>"
else
   echo "<result>FileVaultMaster Not found</result>"
fi

Forum|alt.badge.img+33
  • Hall of Fame
  • May 6, 2013

This may be an easier approach:

#!/bin/sh

# looks for the FVMaster keychain

if [ -f "/Library/Keychains/FileVaultMaster.keychain" ]; then
   echo "<result>FileVaultMaster detected</result>"
else
   echo "<result>FileVaultMaster Not found</result>"
fi

Forum|alt.badge.img+33
  • Hall of Fame
  • May 6, 2013

Heh, beat me to it.