Monthly Archives: November 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"
wget $(curl -L 2>/dev/null | grep 'format=zip' | head -1 | cut -d\' -f4) -O
if [[ -d "AirMail" ]]; then
    rm -rf "AirMail"
echo "unzip"
unzip 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" ]]; then
    echo "rename current"
    mv "/Applications/AirMail" "/Applications/AirMail Beta"
echo "copy new to applications directory"
mv "AirMail" /Applications/
echo "cleanup"
rm -rf "/Applications/AirMail Beta"
if [[ ! -z ${PID} ]]; then
    echo "restart"
    open -g "/Applications/AirMail"
echo "done"