As we get new computers for users, to transfer the data from old to new, we use a script in self service that runs rysnc between the computers connected via target disk mode, works great. I'd love to improve this by having the rysnc progress in an active dialog verbose dialog box so our Team can track the progress. Can any script gurus help me get that implemented into our script below?
# Get username
username=$(/usr/bin/osascript<<END
tell application "System Events"
activate
set the answer to text returned of (display dialog "Enter the username you want to rsync.
Click Continue and grab some coffee!" default answer "" buttons {"Continue"})
end tell
END)
echo "User paramater passed..."
sleep 1
echo "Working..."
sleep 1
echo "Remove user home folder cache on Macintosh HD 1"
sleep 1
rm -rf /Volumes/Macintosh HD 1/Users/"$username"/Library/Caches/*
sleep 2
echo "Emptying user Trash..."
rm -rf /Volumes/Macintosh HD 1/Users/"$username"/.Trash/*
sleep 2
sleep 1
echo "Working..."
sleep 1
echo "Initializing Migration Assistant..."
sleep 2
echo "Transferring User Data....."
sleep 1
/usr/bin/rsync -av /Volumes/Macintosh HD 1/Users/"$username"/* /Volumes/Macintosh HD/Users/"$username"/
sleep 2
echo "Running Transferring User Data......"
sleep 10
echo "Adjusting File Permissions"
/usr/bin/chmod -R 775 /Volumes/Macintosh HD/Users/"$username"
sleep 1
echo "Adjusting File Ownership..."
/usr/sbin/chown -R "$username":staff /Volumes/Macintosh HD/Users/"$username"
echo "Adjusting File Permissions"
/usr/libexec/repair_packages --repair --standard-pkgs --volume /
echo "Copy complete..."
sleep 1
echo "Transfer Completed Successfully..."
#Prompt Team that transfer was complete
USER=`who | grep console | awk '{print $1}'`
/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType utility -title "Data Migration Utility " -heading "Data Migration Status" -alignHeading center -description "Data transfer has completed, check and compare the sizes of both HDDs while I make this user an admin of this laptop." -icon /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/ToolbarInfo.icns -button1 "OK" -button2 "Cancel" -defaultButton 1 -cancelButton 2
# If the user clicks OK
if [ "$?" == "2" ]; then
echo "Thank you!";
exit 1
# if the user clicks cancel
elif [ "$?" == "2" ]; then
echo "Thank You.";
exit 1
fi
sleep 2
#Add a non-admin user to the admin group
if groups $username | grep -q -w admin;
then
echo "User '$username' already is in the admin group";
else
dscl . -append /Groups/admin GroupMembership $username;
echo "User '$username' has been added to the admin group!";
fi
exit 0
########################################################################################