Setting Account Picture/JPEGPhoto with dscl in terminal
6
votes
2
answers
9091
views
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###
Asked by Dakine83
(235 rep)
Jan 17, 2014, 12:19 AM
Last activity: May 26, 2024, 10:41 AM
Last activity: May 26, 2024, 10:41 AM