Tag Archives: airmail

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.

#!/bin/bash
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"
fi
 
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}
fi
 
if [[ -d "/Applications/AirMail Beta.app" ]]; then
    echo "rename current airmail.app"
    mv "/Applications/AirMail Beta.app" "/Applications/AirMail Beta old.app"
fi
 
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"
fi
echo "done"