Skip to main content
Question

Login Script for local user not working. Using dockutil and launchd

  • September 24, 2014
  • 4 replies
  • 3 views

Forum|alt.badge.img+6
  • New Contributor
  • 5 replies

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: 8
29/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/bash
2THEUSER=students
3#user name
4SCPFOLDER=/Users/$THEUSER/Library/Scripts
5#Dockutil config folder
6OCFOLDER="/Users/$THEUSER/Library/LaunchAgents/"
7
8
9mkdir -p "$SCPFOLDER";
10mkdir -p "$OCFOLDER";
11# make folders above
12
13sudo chown -R $THEUSER "$SCPFOLDER";
14#change to owner to current user
15
16cat > "$SCPFOLDER/studentsdock.sh" <<EOF
17 /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"
34EOF
35# write script with dockutil settings
36
37cat > "$OCFOLDER/com.deltaschools.dockutill.plist" <<EOF
38<?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>
50EOF
51# write plist to launch studentdock.sh script
52
53chmod a+x "$SCPFOLDER/studentsdock.sh"
54#make script run
55launchctl 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"

4 replies

mm2270
Forum|alt.badge.img+24
  • Legendary Contributor
  • 7886 replies
  • September 24, 2014

So, you're creating the LaunchAgent via script? The problem most likely is the permissions aren't being set right on the resulting launchd plist. LaunchAgents and LaunchDaemons are very finicky about permissions and will not run if things are not set just so. Although the error doesn't specifically state that as the issue, try adding the following to your script after the lines where you create the plist.

1chown root:wheel /Library/LaunchAgents/com.deltaschools.dockutill.plist
2chmod 644 /Library/LaunchAgents/com.deltaschools.dockutill.plist

launchd's need 644 and root:wheel as above. So give that a shot and see if it runs. if not, post back with any updated error information.


Forum|alt.badge.img+6
  • Author
  • New Contributor
  • 5 replies
  • September 24, 2014

Same error sadly

19/24/14 10:09:02.416 AM com.apple.launchd.peruser.600[798]: (com.deltaschools.dockutil[7421]) Job failed to exec(3) for weird reason: 8
2
3
4
5
6
7ls -l outputs
8drwxr-xr-x 3 students 600 102 Sep 23 17:01 Scripts
9-rwxr-xr-x@ 1 students 600 1407 Sep 24 10:08 studentsdock.sh
10
11
12
13
14
15drwxr-xr-x 3 root 600 102 Sep 23 15:21 LaunchAgents
16-rw-r--r-- 1 root wheel 375 Sep 24 10:08 com.deltaschools.dockutill.plist
17
18
19
20
21
22C02N3QSHG086:LaunchAgents students$ launchctl list
23PID Status Label
24
25
26
27
    1
    2
  • 18 com.deltaschools.dockutil

I listed some outputs on the permissions if that helps .


Forum|alt.badge.img+6
  • Author
  • New Contributor
  • 5 replies
  • September 24, 2014

I also tried setting the script to 644 and now the error is

19/24/14 10:42:50.938 AM com.apple.launchd.peruser.600[832]: (com.deltaschools.dockutil[882]) Exited with code: 13

mm2270
Forum|alt.badge.img+24
  • Legendary Contributor
  • 7886 replies
  • September 24, 2014

What happens if you manually try loading the LaunchAgent? Also, you might want to consider using an application designed to create launchd's, like LaunchControl! or the older Lingon.
Although its possible to create them manually or from a script, I've found I've had far better luck in allowing an application to create them so the formatting, permissions and everything else is set correctly. As I said, they are quite finicky and won't run if things are even slightly out of order.

Is there a specific need to create it and load it directly from a script, or is it possible to create it and package it up in a pkg deployment? You may have better luck trying it that way.
Anyway, give one of those applications a shot as a first test. If it works after recreating it in one of those apps, then it points to how your script is creating the LaunchAgent.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings