I've had great sussecces with using dockutil for our network accounts. At our school we have a generic local account named students incase of network outage or other problems. I'm trying to modify the dock of this generic account so that the dock goes back to a set state at each login. I've read I should try and not use loginhooks anymore and instead use a launch agent events.
I've followed the suggestions here http://stackoverflow.com/questions/1370901/very-simple-launchd-plist-not-running-my-script
The script made can be run by the students account and without error
In the logs I get this odd error from launchd
1(com.deltaschools.dockutil.app[2944]) Job failed to exec(3) for weird reason: 829/23/14 3:46:17.087 PM com.apple.launchd.peruser.600[807]:39/23/14 3:46:18.116 PM com.apple.launchd.peruser.600[807]: (com.deltaschools.dockutil.plist) Job should be able to exec(3) now.
Here is my JSS script.
1#!/bin/bash2THEUSER=students3#user name4SCPFOLDER=/Users/$THEUSER/Library/Scripts5#Dockutil config folder6OCFOLDER="/Users/$THEUSER/Library/LaunchAgents/"789mkdir -p "$SCPFOLDER";10mkdir -p "$OCFOLDER";11# make folders above1213sudo chown -R $THEUSER "$SCPFOLDER";14#change to owner to current user1516cat > "$SCPFOLDER/studentsdock.sh" <<EOF17 /usr/bin/dockutil --remove all "/Users/students" 18 /usr/bin/dockutil --add "/Applications/Safari.app" "/Users/students" 19 /usr/bin/dockutil --add "/Applications/Firefox.app" "/Users/students" 20 /usr/bin/dockutil --add "/Applications/Google Chrome.app" "/Users/students" 21 /usr/bin/dockutil --add "/Applications/Microsoft Office 2011/Microsoft Word.app" "/Users/students" 22 /usr/bin/dockutil --add "/Applications/Microsoft Office 2011/Microsoft Excel.app" "/Users/students" 23 /usr/bin/dockutil --add "/Applications/Microsoft Office 2011/Microsoft PowerPoint.app" "/Users/students" 24 /usr/bin/dockutil --add "/Applications/Keynote.app" "/Users/students" 25 /usr/bin/dockutil --add "/Applications/Numbers.app" "/Users/students" 26 /usr/bin/dockutil --add "/Applications/Pages.app" "/Users/students" 27 /usr/bin/dockutil --add "/Applications/Calculator.app" "/Users/students" 28 /usr/bin/dockutil --add "/Applications/Calendar.app" "/Users/students" 29 /usr/bin/dockutil --add http://online3.typingmaster.com/login?id=pfn84kh57 --label "TypingMaster Online" 30 /usr/bin/dockutil --add https://cloud.deltaschools.com --label "DCSD Cloud Storage" 31 /usr/bin/dockutil --add /Applications --view list --sort name "/Users/students" 32 /usr/bin/dockutil --add /Users/students/Downloads --view list --sort name "/Users/students" 33 /usr/bin/dockutil --add /Users/students/Documents --view list --sort name "/Users/students" 34EOF35# write script with dockutil settings3637cat > "$OCFOLDER/com.deltaschools.dockutill.plist" <<EOF38<?xml version="1.0" encoding="UTF-8"?>39<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">40<plist version="1.0">41 <dict>42 <key>Label</key>43 <string>com.deltaschools.dockutil</string>44 <key>Program</key>45 <string>$SCPFOLDER/studentsdock.sh</string>46 <key>RunAtLoad</key>47 <true/>48 </dict>49</plist>50EOF51# write plist to launch studentdock.sh script5253chmod a+x "$SCPFOLDER/studentsdock.sh"54#make script run55launchctl load -wF "$OCFOLDER/com.deltaschools.dockutill.plist"56# add plist to launchctl
Files made from running script in casper remote com.deltaschools.dockutill.plist
1<?xml version="1.0" encoding="UTF-8"?>2<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">3<plist version="1.0">4 <dict>5 <key>Label</key>6 <string>com.deltaschools.dockutil</string>7 <key>Program</key>8 <string>/Users/students/Library/Scripts/studentsdock.sh</string>9 <key>RunAtLoad</key>10 <true/>11 </dict>12</plist>
studentsdock.sh
1/usr/bin/dockutil --remove all "/Users/students" 2 /usr/bin/dockutil --add "/Applications/Safari.app" "/Users/students" 3 /usr/bin/dockutil --add "/Applications/Firefox.app" "/Users/students" 4 /usr/bin/dockutil --add "/Applications/Google Chrome.app" "/Users/students" 5 /usr/bin/dockutil --add "/Applications/Microsoft Office 2011/Microsoft Word.app" "/Users/students" 6 /usr/bin/dockutil --add "/Applications/Microsoft Office 2011/Microsoft Excel.app" "/Users/students" 7 /usr/bin/dockutil --add "/Applications/Microsoft Office 2011/Microsoft PowerPoint.app" "/Users/students" 8 /usr/bin/dockutil --add "/Applications/Keynote.app" "/Users/students" 9 /usr/bin/dockutil --add "/Applications/Numbers.app" "/Users/students" 10 /usr/bin/dockutil --add "/Applications/Pages.app" "/Users/students" 11 /usr/bin/dockutil --add "/Applications/Calculator.app" "/Users/students" 12 /usr/bin/dockutil --add "/Applications/Calendar.app" "/Users/students" 13 /usr/bin/dockutil --add http://online3.typingmaster.com/login?id=pfn84kh57 --label "TypingMaster Online" 14 /usr/bin/dockutil --add https://cloud.deltaschools.com --label "DCSD Cloud Storage" 15 /usr/bin/dockutil --add /Applications --view list --sort name "/Users/students" 16 /usr/bin/dockutil --add /Users/students/Downloads --view list --sort name "/Users/students" 17 /usr/bin/dockutil --add /Users/students/Documents --view list --sort name "/Users/students"