#!/bin/bash
## For keeping Homebrew up-to-date.
## Place in /usr/local/bin/ as a "brewup."
## Use launchd to run this script on the regular (try Lignon 3 if you're not familiar with launchd).
## Assumes you have homebrew installed. Assumes you're using a contemporary version of macOS.
## Borrows from Mike Bradshaw (github:bmike) http://apple.stackexchange.com/questions/206465/auto-updating-homebrew
## Borrows from Jason Cooper (github:boogah) https://gist.github.com/boogah/cdbbd337b0b447175061
brew=/usr/local/bin/brew
logger=/usr/bin/logger
echo "######### `date`: RUNNING: brew update" 2>&1 | $logger -t brewup.update
$brew update -v 2>&1 | $logger -t brewup.update
echo "`date`: FINISHED: brew update" 2>&1 | $logger -t brewup.update
echo "######### `date`: RUNNING: brew upgrade #########" 2>&1 | $logger -t brewup.update
$brew upgrade -v 2>&1 | $logger -t brewup.upgrade
echo "`date`: FINISHED: brew upgrade" 2>&1 | $logger -t brewup.update
echo "######### `date`: RUNNING: brew cleanup #########" 2>&1 | $logger -t brewup.update
$brew cleanup -v 2>&1 | $logger -t brewup.cleanup
echo "`date`: FINISHED: brew cleanup" 2>&1 | $logger -t brewup.update
echo "Scheduled Homebrew update complete. Enjoy a cold one! " 2>&1 | $logger -t brewup.update