The following bash script will retrieve a list of existing, normal users on a macOS device and copy the specified file(s) to the users' home folders. These can be added to a worklet for use with Automox.
Note: Be sure to modify the UHOME variable with the path to the Users folder, if different from "/Users".
Modify the _FILES variable with the full path to the file(s) you want to copy, including the filename(s).
#!/bin/bash
#Base home folder
UHOME="/Users"
#Path to files to be copied
_FILES="./test_file ./test_file2"
#Get a list of all normal users
_USERS="$(dscl . list /Users | grep -v '_')"
#Iterate through user list and file list and copy files
for u in $_USERS
do
for f in $_FILES
do
_dir="${UHOME}/${u}"
#check that the directory exists
if [ -d "$_dir" ]
then
/bin/cp -f "$f" "$_dir"
file_name=`basename ${f}`
#set permissions
chown $(id -un $u):$(id -gn $u) "$_dir/${file_name}"
fi
done
done
Comments
0 comments
Article is closed for comments.