Recently, I've been taking advantage of Apple's 14-day Return Policy on Macbooks to try out different models. In order to avoid losing valuable time reinstalling and configuring the machines, I've started automating setup of my entire environment.
For the most part I did this by writing scripts to install brew packages, gems, and npm modules. However, I found that I'd go to open a package and found that I had forgotten to go to the website, install it, configure it, etc.
I knew I needed a way to 1) track the applications that I use 2) Automatically install them when I start developing on a new machine. As a side bonus, I wanted to unmount and remove the .dmg file after installation.
I've written several bash scripts to congiure my machine. Here's the script to install a .dmg file. This example uses pgAdmin3 which I use for Postgresql / Rails development.
#!/usr/bin/env bash # Install pgAdmin3 using bash # https://github.com/grantgeorge/dotfiles/blob/master/pgadmin.sh # Ask for the administrator password upfront. sudo -v # Keep-alive: update existing `sudo` time stamp until the script has finished. while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null & # Download - note wget must be installed (I install through brew) wget -O ~/Desktop/pgadmin3-1.20.0.dmg https://ftp.postgresql.org/pub/pgadmin3/release/v1.20.0/osx/pgadmin3-1.20.0.dmg # Mount and install hdiutil mount ~/Desktop/pgadmin3-1.20.0.dmg sudo cp -R "/Volumes/pgAdmin3/pgAdmin3.app" /Applications # Cleanup - unmount and remove source file hdiutil unmount "/Volumes/pgAdmin3/" rm ~/Desktop/pgadmin3-1.20.0.dmg # Verify it's installed correctly ls -la /Applications | grep 'pgAdmin3.app' echo "Done. Ensure that pgAdmin3.app is in the /Applications folder!"
The source is available on my GitHub:
Check out the dotfiles repo for other automation / recipes!