Skip to main content

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

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



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


Try this instead:



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

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

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

Heh, beat me to it.