tools/dmg_pkg_install.sh
author Wuzzy <Wuzzy2@mail.ru>
Sat, 27 Oct 2018 15:55:19 +0200
changeset 14014 f09276eb0c27
parent 11587 cf83d9cb5590
permissions -rw-r--r--
Add 7 new taunts New sounds: * Bugger, Drat: Hog damages self only * Thisoneismine: Crate drop * Whatthe: Something is going to blow up close to hog * Solong, Ohdear: Death * Gonnagetyou: Vow for revenge Fallback code is added for existing voicepacks Thisoneismine is not used in Robot because the text in this sound file is "Threat detected.", which does not make sense.

#!/bin/bash

# Downloads and install a .dmg from a URL
#
# Usage
# $ dmg_pkg_install [url]
#
# Adopted from https://gist.github.com/afgomez/4172338


if [[ $# -lt 1 ]]; then
  echo "Usage: dmg_pkg_install [url]"
  exit 1
fi

url=$*

# Generate a random file name
tmp_file=/tmp/`openssl rand -base64 10 | tr -dc '[:alnum:]'`.dmg

# Download file
echo "Downloading $url..."
curl -# -L -o $tmp_file $url

echo "Mounting image..."
volume=`hdiutil mount $tmp_file | tail -n1 | perl -nle '/(\/Volumes\/[^ ]+)/; print $1'`

# Locate .pkg
app_pkg=`find $volume/. -name *.pkg -maxdepth 1 -print0`
echo "Install pkg..."
installer -pkg $app_pkg -target /

# Unmount volume, delete temporal file
echo "Cleaning up..."
hdiutil unmount $volume -quiet
rm $tmp_file

echo "Done!"
exit 0