09-18-2023 10:33 AM - edited 09-18-2023 10:48 AM
Wrote this quick one today to be used in our enrolment script. I checks if a user is bound to a specific departement and run a Installomator app install based on that. It also checks if app already are installed. In the example we install Adobe Creative cloud desktop to users in Marketing.
#!/bin/bash
#########################################################################################################
JCAPIKey='YOUR API KEY'
department="Marketing" #If users are in this departement app will install
installomatorapp="adobecreativeclouddesktop" #Installomator install name
installedappdir="/Applications/Utilities/Adobe Creative Cloud/" #Directory to check if app is installed
#########################################################################################################
#Check local username
username="$(cat /opt/jc/managedUsers.json | sed -n 's/.*"username":"//p' | awk -F '\\",' '{print ($1)}')"
#Check if user are in departement
ingroup="$(curl -s -X POST https://console.jumpcloud.com/api/search/systemusers \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-H 'x-api-key: '$JCAPIKey'' \
-d '{
"searchFilter": {
"searchTerm": "$username",
"fields": ["username"]
},
"filter": {
"or": [
{"department" : "$department"}
]
},
"fields" : "username"
}')"
#Crosscheck local user with API call
usercheck="$(echo $ingroup | grep -o "$username")"
#Install if user is in group and App not installed.
if [ ! "$usercheck" == "$username" ]; then
echo "Not in $department Exiting"
exit 0
elif [ -d "$installedappdir" ]; then
echo "$installomatorapp Already Installed"
exit 0
else
echo "Installing $installomatorapp"
cd /usr/local/Installomator/
./Installomator.sh $installomatorapp
fi
New to the site? Take a look at these additional resources:
Ready to join us? You can register here.