Skip to main content

Okay, this may sound a bit odd given my shell scripting experience, but I need help. It's probably something stupid. Here's the script I've got:



#!/bin/ksh

# Filename: mountShares.sh
# Purpose: Mount file shares automatically with Kerberos ticket
# Author: Jared F. Nichols

user=`ls -la /dev/console | cut -d " " -f 4`
server=`dscl . -read /Users/$user | grep SMBHome: | cut -d '' -f 3`

jamf mount -server $server -share $user -type smb

defaults write com.apple.dock persistent-others -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Volumes/$user</string><key>_CFURLStringType</key><integer>0</integer></dict><key>showas</key><integer>2</integer></dict><key>tile-type</key><string>directory-tile</string></dict>'

killall Dock


The gist is that it will take a kerberos ticket, mount a server share and then put the share in the dock. My issue is that for the life of me I can't get $user to resolve. Defaults puts a literal "$user" in on the dock. I've tried all manner of escaping it, quoting, setting the defaults as another variable (which can get it to resolve properly) and then, essentially, run the variable - all to no effect.



Any ideas?? I should be able to lick this one but it's kicking my arse.

My first thought was MCX as well, but I didn't have time to test it out. I do vaguely remember something in WGM that allowed you to do this, I think. Been a while since I had to use OD to Manage Macs so I am starting to forget some of it.



-Tom


I originally tried MCX to plant the volume there, but due to every login essentially being an offline login with FV2, it didn't quite work the way I expected and you'd get an error that the system couldn't connect to the server. The script was really just an easy way for techs to setup a "drive map." More a stop-gap solution than anything else.


Reply