dotfiles/includes/installer.sh

56 lines
1.1 KiB
Bash
Raw Normal View History

2012-10-22 11:11:46 +00:00
#!/bin/bash
# Utils to install OSX apps in various formats
# Based on https://github.com/bkuhlmann/osx/blob/master/functions/installers.sh
INSTALLER_DIR=`mktemp -d`
# Downloads an installer to local disk
#
# @param $1 URL
# @param $2 File name
2012-10-23 08:55:52 +00:00
function download_installer {
2012-10-22 11:11:46 +00:00
echo "Downloading $1/$2..."
cd "$INSTALLER_DIR"
curl -LO "$1/$2"
cd ..
}
# Installs an application
#
# @param Application folder
# @param Application name
function install_app {
echo "Installing $2.app..."
2012-10-23 08:47:00 +00:00
cp -a "$1/$2.app" "/Applications/"
2012-10-22 11:11:46 +00:00
}
# Installs an application via a DMG file
#
# @param $1 Donwload URL
# @param $2 Download file name
# @param $3 Mount path
# @param $4 App name
function install_dmg_app {
mount_point="/Volumes/$3"
download_installer "$1" "$2"
download_file="$INSTALLER_DIR/$2"
echo "Mounting $2..."
hdiutil attach "$download_file" -noverify -readonly -noautoopenro -noidmereveal
install_app "$mount_point" "$4"
echo "Cleaning..."
hdiutil detach -force "$mount_point"
rm -f "$download_file"
}
# Removes temporary directory
function install_cleanup {
rm -rf "$INSTALLER_DIR"
}