New to MDS, problem running scripts

New to using MDS. Right now I have to set up devices with two workflows. One workflow creates and admin account and a standard account. Then, it installs a couple of packages. Second workflow installs scripts. It seems like I have to run the first workflow. Then, sign into both accounts. Then, run the second workflow. This is the only way I’ve been able to get my m1 devices setup in the way that I want them setup.

If I try to use a single workflow to create both accounts, install packages, and run scripts, I end with an admin account (no scripts ran), and a standard account that is missing all of its default directories (Downloads, Documents, ect).

I’ve tried reordering when the scripts run, but it doesn’t seem to help. The only thing that has helped is running the scripts in a separate workflow after the accounts have been created.

Any advice for me? I’ve tested all the scripts individually and they work as intended.

So to replicate your issue, just create 2 user accounts and run a script? What is the script that you are running?

I recommend joining the mac admin slack and the #twocanoes-mds channel.

tim

Thanks for your help. Yes, I’m creating an admin and standard user. Then, I’m installing a launch daemon into /Library/LaunchDaemons that runs a script in /usr/local/bin. In the admin account, I’m installing a finder and dock plist, and a few miscellaneous files. In the standard user account, I’m installing a launch agent into ~/Library/LaunchAgents that runs a script in the users home directory. I’m also installing a dock plist and other miscellaneous files into the standard user account. Each installation task is broken up into it us own MDS script. Here’s one of my MDS scripts.

#########################################
#!/bin/bash
scriptName=basename $0
scriptDir=$(dirname $0)
sourceDir=$scriptDir/Resources
group=wheel
user=root
destDir=/usr/local/bin
file=set-host-name-to-disk-name.sh
if [ ! -e $destDir ]
then
mkdir -p $destDir
fi
/bin/cp $sourceDir/$file $destDir/$file
/bin/chmod 755 $destDir/$file
/usr/sbin/chown $user:$group $destDir/$file
exit 0
#########################################

Here’s another one of my scripts.

#########################################
#!/bin/bash
scriptName=basename $0
scriptDir=$(dirname $0)
sourceDir=$scriptDir/Resources
group=staff
user=admin
destDir=/Users/$user
bashProfile=$sourceDir/bash_profile
bashRC=$sourceDir/bashrc
vimRC=$sourceDir/vimRC
dotBashProfile=$destDir/.bash_profile
dotBashRC=$destDir/.bashrc
dotVimRC=$destDir/.vimrc

/bin/cp $bashProfile $dotBashProfile
/bin/cp $bashRC $dotBashRC
/bin/cp $vimRC $dotVimRC

/bin/chmod 600 $dotBashProfile
/bin/chmod 600 $dotBashRC
/bin/chmod 600 $dotVimRC

/usr/sbin/chown $user:$group $dotBashProfile
/usr/sbin/chown $user:$group $dotBashRC
/usr/sbin/chown $user:$group $dotVimRC
exit 0
#########################################

The issue is probably that the user home directories have not been created yet and you are creating some folders. Add “createhomedir -c” at the top of your script to force any users that have directory services accounts to have home directories created.

As for copying items into the home directory, TCC may be protecting some of the folders. I usually modify the user template before users are created then it will use the files added to the template when creating the home directory.

tim

Thanks for the quick response! “createhomedir -c -u teacher” did the trick for my standard user account called teacher, but I’m still having problems with the admin account. Running “createhomedir -c -u admin” didn’t seem to help. Also, where can I read about creating user templates? Sorry for all of the rookie questions. I work for a public school and I’m trying to get M1 MacBooks deployed for my school, but my technical ability is limited. Thanks again for the help that you’ve given me.

Sorry, I got it now. I had “createhomedir -c -u admin” out of order. In my workflow, I adjusted the sequence of my scripts. Now it works!!! Thanks for all of your help.