Skip to content

Instantly share code, notes, and snippets.

@vaites
Created November 29, 2014 16:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vaites/3302f114539bbf6aab0d to your computer and use it in GitHub Desktop.
Save vaites/3302f114539bbf6aab0d to your computer and use it in GitHub Desktop.
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