Tried to be sneaky.. but failed.

ImAMacGuy
Valued Contributor II

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
3 ACCEPTED SOLUTIONS

stevewood
Honored Contributor II
Honored Contributor II

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

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

Try this instead:

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

View solution in original post

JPDyson
Valued Contributor

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

View solution in original post

rtrouton
Release Candidate Programs Tester

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

View solution in original post

4 REPLIES 4

stevewood
Honored Contributor II
Honored Contributor II

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

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

Try this instead:

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

JPDyson
Valued Contributor

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

rtrouton
Release Candidate Programs Tester

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

rtrouton
Release Candidate Programs Tester

Heh, beat me to it.