Thanks Tim your F**kin awesome lol
Here is what i use now for self service
#!/bin/bash
# Environment variable for the home directory of the account
FILE=/private/var/vnc
USER=dscl /Local/Default -list /Users | grep vnc
# Check to see if the account exists in dscl and the home folder
if [ "$USER" ] && [ $FILE ]; then
# If found echo it exists to the shell
echo "vnc account exists"
else
# If the account and home folder doesn't exist then go and create it
/usr/sbin/jamf createAccount -hiddenUser -username vnc -realname vnc -password DrillHall -home /private/var/vnc
fi
# GETTING THE CURRENT CONSOLE USER
rluser=ls -l /dev/console | cut -d " " -f4 | grep rufusleonard.hq
# SEE IF THE GROUP EXISTS
if
dscl . list /groups | grep com.apple.local.ard_interact
then
echo "Group already exists"
# CREATE THE GROUP IF DOESN'T EXIST
else
dscl . -create /groups/com.apple.local.ard_interact
dscl . -create /groups/com.apple.local.ard_interact PrimaryGroupID 1025
fi
# SEE IF CONSOLE USER IS IN THE GROUP
if
dscl . read /groups/com.apple.local.ard_interact | grep ${rluser}
then
echo "rluser is already in the group"
# DISPLAY A MESSAGE
jamf displayMessage -message "Group already exists!
${rluser} is already a member of it!
You don't need to run this anymore!"
# ADD THE CONSOLE USER IF NOT IN THE GROUP
else
dscl . -append /groups/com.apple.local.ard_interact GroupMembership ${rluser}
# DISPLAY A MESSAGE
jamf displayMessage -message "Group created
${rluser} is now a member of the group
vnc account created and the default password must be changed!"
fi
# Allow the local vnc account to control and observe modifying the trigger file
touch /Library/Management/Triggers/adminremotemanagement