0

I'm working on a script based on this question: What steps are needed to create a new user from the command line on Mountain Lion?

The script is packaged up in an empty installer as a postflight script.

It's all working well enough - however, I cannot get the Account picture set. I can use dscl to set the Picture property to an image file, for example the default Apple Account photos.

I can even copy a photo I include in the package over to a number of directories, including /Users/newAccount/Public. But the permissions are messed up and no one but the newAccount can view the profile image. I am unable to chmod the file. Instead, I have to use the GUI and "get info -> Set Permissions"

The other option that I can see is if I set the JPEGPhoto value. This is what happens when you use a custom photo or take one in photobooth. However, I'm not sure how to convert the photo I include in the installer into Hex or Whatever is being stored in the JPEGPhoto value.

Thanks! - Chris

Edit: Added script. Everything works in this script - the picture just won't display, due to permissions. The path is set properly. I've tried to place it several different locations that have shared access, but no matter what the permissions are wrong and I cannot chmod them.

###CREATE TP ADMINISTRATOR ACCOUNT###

LastID=`dscl . -list /Users UniqueID | awk '{print $2}' | sort -n | tail -1`

NextID=$((LastID + 1))
. /etc/rc.common
dscl . create /Users/administrator

dscl . create /Users/administrator RealName "Administrator Account"
dscl . create /Users/administrator hint "the password Duh"

dscl . passwd /Users/administrator password
dscl . create /Users/administrator UniqueID $NextID
dscl . create /Users/administrator PrimaryGroupID 80
dscl . create /Users/administrator UserShell /bin/bash
dscl . create /Users/administrator NFSHomeDirectory /Users/administrator
cp -R /System/Library/User\ Template/English.lproj /Users/administrator
chown -R administrator:staff /Users/administrator

cp $1"/Contents/Resources/admin.jpg" /Users/administrator/Public
dscl . create /Users/administrator Picture "/Users/administrator/Public/admin.jpg"

###CREATE TP ADMINISTRATOR ACCOUNT###
  • Chris, could you show us the script you currently have? It should work fine to set the 'picture' value to one of the Apple default ones. – Tony Williams Jan 17 '14 at 6:03
  • Also, you realise you are only setting the login icon here? Oh, and are you being careful of spaces in the path? – Tony Williams Jan 17 '14 at 6:16
  • Hi Tony, as I said I am able to set it to the apple default pictures. And the path is correct, but when I move the file I end up with permissions that only allow root to view the image. I am unable to chmod the file. – Dakine83 Jan 20 '14 at 18:15
  • Yep, I know it's just the picture, and not that important. It was more of a frustration than a requirement. I will post the script shortly, though I mangled it in an attempt to get the permissions working properly. – Dakine83 Jan 20 '14 at 18:16

You must log in to answer this question.

Browse other questions tagged .