My company is starting to roll out our company fonts. Some computers already have them installed, and some don't. If I just push the fonts through a policy it installs in /Library/Fonts/Managed, but if they were installed by the user previously they'll be in /Users/<user>/Library/Fonts. The ones installed through the policy also modify the file names, which may or may not be the cause of the issue I'm trying to alleviate: duplicate fonts.
I'm installing a total of 84 fonts, all belonging to the same font family (or 2 font families, because mono spaced fonts are its own section in the font book). I attempted to create an extension attribute that will look for fonts installed by the user, and if the name is found and file count is at >84 it'll output true, else false. With this, I planned to create a smart group with which I can assign the new policy. However, the script on the extension attribute doesn't appear to be working properly (the count is outputting 1, not 85 like I get in terminal)(also, I'm super new to shell scripting), so I'm wondering: is creating an extension attribute and/or smart group the best way to make sure I'm not duplicating user installed fonts?
I also want to know what's wrong with what I've written, so insight into both the over arching question, and the script would be helpful!
#!/bin/sh
#Get current signed in user
currentUser=$(ls -l /dev/console | awk '/ / { print $3 }')
#Get User Font Library
fontLibrary=$(ls -l /Users/$currentUser/Library/Fonts | awk '/ / { print $9 }')
#count fonts present (extra line accounted for in if statement)
#there are a total of 84 fonts in the GT America library
count=$(echo $fontLibrary | wc -l | awk '{ $1=$1;print }')
#GT Found
found=$([[ $fontLibrary =~ .*GT-America.* ]] && echo "True" || echo "False")
#results
if [[ $count > 84 && $found == "True" ]]
then
echo "<result>True</result>"
else
echo "<result>False</result>"
fi