author Justin Wood <>
Wed, 19 Feb 2014 14:10:27 -0500
changeset 4387 19569ea375a72b6799c3b56c0361eb45648a767d
parent 2984 ab1e1ce9595fdd8b12e8be8137e4ee3f5a90e56a
permissions -rwxr-xr-x
Bug 971790 - add new masters to production-masters.json disabled. r=armenzg

# How long to wait before giving up waiting for the mount to fininsh

# If mnt already exists, then the previous run may not have cleaned up
# properly.  We should try to umount and remove the mnt directory.
if [ -d mnt ]; then
    echo "mnt already exists, trying to clean up"
    hdiutil detach mnt -force
    rm -rdf mnt

# Install an on-exit handler that will unmount and remove the 'mnt' directory
trap "{ if [ -d mnt ]; then hdiutil detach mnt -force; rm -rdfv mnt; fi; }" EXIT

mkdir -p mnt

hdiutil attach -noautoopen -mountpoint ./mnt "$1"
# Wait for files to show up
# hdiutil uses a helper process, diskimages-helper, which isn't always done its
# work by the time hdiutil exits.  So we wait until something shows up in the
# mnt directory.
while [ "$(echo mnt/*)" == "mnt/*" ]; do
    if [ $i -gt $TIMEOUT ]; then
        echo "No files found, exiting"
        exit 1
    sleep 1
    i=$(expr $i + 1)
# Now we can copy everything out of the mnt directory into the current directory
rsync -a ./mnt/* .
hdiutil detach mnt
rm -rdf mnt
# Sleep for a bit to let messages from diskimage-helper go away
sleep 5