Daily Archives: November 2, 2013

script to update AirMail Beta

AirMail Beta is updated so frequently that I am getting quite annoyed by having to download and extract and copy the new build from the same link over and over again. So here’s a no-brainer bash script which does these repetitive manual actions.

echo "downloading airmail.zip"
wget $(curl -L http://airmailapp.com/beta 2>/dev/null | grep 'format=zip' | head -1 | cut -d\' -f4) -O airmail.zip
if [[ -d "AirMail Beta.app" ]]; then
    rm -rf "AirMail Beta.app"
echo "unzip airmail.zip"
unzip airmail.zip 2>&1 1>/dev/null
PID=$(ps -A | grep "AirMail Beta" | grep -v grep | awk {'printf $1}')
if [[ ! -z ${PID} ]]; then
    echo "kill running airmail (${PID})"
    kill ${PID}
if [[ -d "/Applications/AirMail Beta.app" ]]; then
    echo "rename current airmail.app"
    mv "/Applications/AirMail Beta.app" "/Applications/AirMail Beta old.app"
echo "copy new airmail.app to applications directory"
mv "AirMail Beta.app" /Applications/
echo "cleanup"
rm airmail.zip
rm -rf "/Applications/AirMail Beta old.app"
if [[ ! -z ${PID} ]]; then
    echo "restart airmail.app"
    open -g "/Applications/AirMail Beta.app"
echo "done"