We use DEPNotify as part of our deployment process so we can see which stage the process has got to.
As part of this, we use defaults write to set up the .plist needed to allow DEPNotify to show a "registration" dialog that lets us specify the name and role (staff/student) of the Mac.
On Monterey (12.2.1) on brand new Apple Silicon M1 iMacs, this seems to be failing for some reason.
In the logs we can see:
2022-07-26 10:12:08.279056+0100 0x69fea Activity 0x5e290 10301 0 defaults: (CoreFoundation) Loading Preferences From System CFPrefsD
2022-07-26 10:12:08.297138+0100 0x69fff Activity 0x5e2c0 10311 0 defaults: (libsystem_info.dylib) Retrieve User by ID
2022-07-26 10:12:08.306905+0100 0x69fff Error 0x0 10311 0 defaults: (CoreFoundation) [com.apple.defaults:User Defaults] Couldn't write values for keys (
registrationMainTitle
) in CFPrefsPlistSource<0x600001394500> (Domain: menu.nomad.DEPNotify, User: kCFPreferencesCurrentUser, ByHost: No, Container: (null), Contents Need Refresh: Yes): Domain or user not found, detaching from cfprefsd
2022-07-26 10:12:08.306913+0100 0x69fff Activity 0x5e2c1 10311 0 defaults: (CoreFoundation) Flushing Cached Preferences Data
2022-07-26 10:12:08.306963+0100 0x69fff Default 0x0 10311 0 defaults: Could not write domain menu.nomad.DEPNotify; exiting
Can anyone suggest what might be causing this? The script works fine if run from Terminal.
The commands being used are:
imagePath="${4}"
loggedInUser=$( scutil <<< "show State:/Users/ConsoleUser" | awk '/Name :/ && ! /loginwindow/ { print $3 }' )
/usr/bin/sudo -u "${loggedInUser}" /usr/bin/defaults write menu.nomad.DEPNotify registrationMainTitle "Configuration of this Mac"
/usr/bin/sudo -u "${loggedInUser}" /usr/bin/defaults write menu.nomad.DEPNotify registrationButtonLabel "Configure"
/usr/bin/sudo -u "${loggedInUser}" /usr/bin/defaults write menu.nomad.DEPNotify registrationPicturePath "${imagePath}"
/usr/bin/sudo -u "${loggedInUser}" /usr/bin/defaults write menu.nomad.DEPNotify statusTextAlignment "center"
# Device Name request
/usr/bin/sudo -u "${loggedInUser}" /usr/bin/defaults write menu.nomad.DEPNotify textField1Label "Device Name"
/usr/bin/sudo -u "${loggedInUser}" /usr/bin/defaults write menu.nomad.DEPNotify textField1Placeholder "Set the Device Name"
/usr/bin/sudo -u "${loggedInUser}" /usr/bin/defaults write menu.nomad.DEPNotify textField1IsOptional false
# Device role request
/usr/bin/sudo -u "${loggedInUser}" /usr/bin/defaults write menu.nomad.DEPNotify popupButton1Label "Machine Role"
machineRoleValues="Student,Staff,Server"
OLDIFS=$IFS
IFS=','
/usr/bin/sudo -u "${loggedInUser}" /usr/bin/defaults write menu.nomad.DEPNotify popupButton1Content -array $machineRoleValues
IFS=$OLDIFS
I've tried adding delays between each defaults write command, I've tried checking that cfprefsd is running, I've tried adding a while loop that checks whether /Users/${loggedInuser}/Library/Preferences/menu.nomad.DEPNotify.plist exists, but none of these seem to help.