Hi everyone, I got to a point, now I am stuck. I am trying to compress the user home folder and then transfer that .zip to a file share. When I run the commands separately the compression works and the transfer works. The issue is that when I try and run them together, the compression never finishes or doesn't report that it is done ( I do occasionally get a zip file of the test account, but the script never continues past the point of the zip command. Here is what I have so far:
#!/bin/sh
# fileshare credentials
shareUsername="user"
password="password"
# network information
# Get the ethernet hardware port (ehwport) and ip address (eipadd)
ehwport=`networksetup -listallhardwareports | awk '/.Ethernet/,/Ethernet Address/' | awk 'NR==2' | cut -d " " -f 2`
# Get the ethernet ip address (eipadd)
eipadd=`ipconfig getifaddr $ehwport`
# get the first six of the addy
eipsubnet=$( echo "$eipadd" | cut -d. -f1,2 )
echo "The ethernet IP address is $eipadd"
# Test the ethernet connection, if not connected exit the script with a message
if [[ "$eipsubnet" != "123.456" ]]; then
/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType utility -title "Wired Network Not Detected" -description "Please connect your computer to the wired network and start the backup program again, thanks!" -button1 "Okay" -defaultButton 1
exit 0
fi
#bring Finder to the front
open .
# user information
loginusername="$(logname)"
echo "The logged in user is $loginusername"
userfolder="$(osascript -e '
tell application "Finder"
display dialog "Please enter you district user name here (first.last)" default answer ""
set userfolder to the (text returned of the result)
end tell')"
echo "The user backup folder will be named $userfolder"
# put in a message in case they canceled the last window or didn't type anything to be able to exit
baduname="$(/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType utility -title "Continue?" -description "If you made a mistake in typing your name in the last window, here is your chance to exit and start over. Press Continue to move forward or Close to start over." -button1 "Continue" -button2 "Close" -defaultButton 2)"
echo "The baduname exit status is $baduname"
if [[ $baduname == 2 ]]; then
exit 0
else
# empty the downloads and trash folders
# folder cleanup
cleanup="$(/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType utility -title "File Clean Up" -description "Is it okay for me to empty your trash and downloads folder now? If yes, the files in those folders will be deleted and the backup process will begin. The backup may take a few minutes to several hours to complete during which your computer will be unavailable. If no, please empty them at your convenience and run the backup program again." -button1 "No" -button2 "Yes" -defaultButton 2)"
echo "The cleanup exit status is $cleanup"
if [[ $cleanup == 0 ]]; then
/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType utility -title "Clear Your Folders" -description "Please save any files from your Downloads and Trash folders and run the program again, thanks!" -button1 "Okay" -defaultButton 1
exit 0
else
rm -rf Users/"$loginusername"/Downloads/*
rm -rf Users/"$loginusername"/.Trash/*
fi
# lock out users from using their computer while this is running
/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType fs -heading "User Backup in Progress" -description "This part of the process may take an extended period of time (from minutes to possibly hours). We appreciate your patience while your computer is running it's backup. This message will automatically clear and your computer will reboot when it is done, thanks!" &
# compress the user home folder
zip -r "$loginusername".zip /Users/"$loginusername"
# mount network share
/usr/sbin/jamf mount -server servername -share sharepoint -type smb -username "$shareUsername" -password "$password"
# make a folder using their district username
mkdir /Volumes/backup/"$userfolder"
# copy archive folder to network share
cp "$loginusername".zip /Volumes/backup/"$userfolder"
# dismount network share
/usr/sbin/jamf unmountServer servername -mountPoint sharepoint
# kill the backup fullscreen window
killall jamfhelper
fi
exit 0
any ideas out there? I appreciate any input on the whole thing as well if something strikes you as bad practice or just plain weird. Thanks!!