RE: How to ignore Shared re: PKG vs DMG

rockpapergoat
Contributor III

using the contents of /Users is less reliable than determining the actual locations of local home directories.

in practice, you may never locate homedirs anywhere but /Users, but i have for various reasons.

in those cases, you might want to do something like the following (cleaned up to exclude accounts you don't need):

for homedir in `dscl . -list /users NFSHomeDirectory | awk '!/^_|root|nobody|Guest/ {print $2}'`; do cp -vR /tmp/stuff "$i/"
done

3 REPLIES 3

tlarkin
Honored Contributor

I have been thinking about this a bit today....while my design wouldn't need this but it is possible for anyone with admin rights to move their home folder in the non default location. Any user account created after imaging will have a UID greater than 500, unless of course you create the user manually and set the UID to a number below 500, and if that is the case then you set this user under UID 500 for it to be hidden, or it runs some sort of system level thing. Like for example when you run quickadd.pkg I think it makes casper ssh account UID 100 and you probably do not want to be altering or adding anything to that account.

So, this is a sort of quick and dirty script to test UID of a user, and if greater than 500 execute something, or in this proof of concept script simply echo out the user's short name. This will just output a list of users who's UID is greater than 500.

#!/bin/bash

#test if UID is over 500, if so execute policy

userID=dscl . list /Users UniqueID | awk '{ print $2 }'

for user in ${userID} ; do

if [ $user -gt 500 ]

then dscl . list /Users UniqueID | grep ${user} | awk '{ print $1 }' fi done exit 0

No idea if this would be useful to anyone, but since it is the end of the day here and I already cleaned up my office and no one else comes back to work till Wednesday I got an hour to kill so I whipped this up.

tlarkin
Honored Contributor

Interesting concept, but by design I know in my images all non IT and non Admin users home folders live in /Users. We run PHDs here, so accounts are synchronized locally, and while if I run your command it actually points to the FQDN path of the user's home directory, however, the changes will not take affect until it is synchronized. So, modifying the local home directory works better, at least in my environment. Plus, Casper does not have permission to run on my OD servers to begin with, so if a script found the full network path it would have no way of mounting that network share and then running a script.

rockpapergoat
Contributor III

in that case, you probably wouldn't want to look for the NFSHomeDirectory. my point was mainly that iterating over the contents of /Users isn't foolproof. if it's good enough for your purposes, then keep on keepin' on.