This isn't directly JAMF related but may be useful to someone once it's working..?
I have a script that installs a certificate then echo's whether it's installed or not after, i'd like to add a check to the beginning to stop the script if a non Active Directory user is logged in but my Script Fu is not yet strong enough. It runs the check but i'm getting "line 5: [: andrew.may: integer expression expected" being returned, any ideas how to clean it up ?
The AD check is from @yr_joelbruner and the Cert check pinched from @ctangora, thank you!
#!/bin/sh
username=$(stat -f%Su /dev/console)
if [ "$username" -lt 1024 ]; then
echo "Non AD user - stopping script"
elif
#install cert from tmp
security add-trusted-cert -d -r trustAsRoot -k "/Users/$username/Library/Keychains/login.keychain" "/private/var/tmp/ourserver.ourdomain.com.cer"
#Check cert is installed
cert_name="ourserver.ourdomain.com"
desired_keychain="/Users/$username/Library/Keychains/login.keychain"
[[ `security find-certificate -c "$cert_name" $desired_keychain 2>/dev/null` ]]; then
echo "installed $cert_name to $username keychain"
else
echo "certificate not installed"
exit 1
fi