Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Upgrade Calibre on Mac OS X to latest version
#!/bin/bash
CALIBRE_DOWN="http://status.calibre-ebook.com/dist/osx32"
CALIBRE_LAST=`curl --head --silent ${CALIBRE_DOWN} | grep "Location" \
| awk '{print $2}' | perl -pi -e 's/\r\n//g'`
CURRENT_USER=`whoami`
CALIBRE_NAME=`echo ${CALIBRE_LAST} | awk -F '/' '{print $5}'`
CALIBRE_FILE="/Users/${CURRENT_USER}/Downloads/${CALIBRE_NAME}"
if [ ! -f $CALIBRE_FILE ]; then
wget "${CALIBRE_LAST}" -O "${CALIBRE_FILE}"
fi
if [ -f $CALIBRE_FILE ]; then
cd "/Applications/"
rm -rf 'Calibre.app'
CALIBRE_VOLUME=`hdiutil attach "${CALIBRE_FILE}" \
| grep "calibre" | awk '{print $3}'`
cp -R "${CALIBRE_VOLUME}/calibre.app" "/Applications/Calibre.app"
hdiutil detach "${CALIBRE_VOLUME}" > /dev/null
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment