#!/bin/bash # # File: feedly-updater.sh # # Keep Feedly for Safari nice and fresh by checking for nightly # updates and installing them # # # Author: Bob Rudis (hrbrmstr) - twitter.com/hrbrmstr # Version: 1.0 # Date: 2009-11-22 # # in the event you roll your own and don't link to std ones CURL="/usr/bin/curl" GREP="/usr/bin/grep" UNZIP="/usr/bin/unzip" # where growlnotify is located GN="/usr/local/bin/growlnotify" # script config vars APP_SUPPORT="$HOME/Library/Application Support/Feedly" LAST_FEEDLY="$APP_SUPPORT/feedly.last" FEEDLY_ZIP="feedly.zip" FEEDLY_URL="http://update.feedly.com/release/$FEEDLY_ZIP" FAVICON_LOCAL="$APP_SUPPORT/Feedly.icns" FAVICON_URL="http://rudis.net/dl/Feedly.icns" LAST_GRABBED="" # # update_feedly() # # Input: the current "Last-Modified" header # # grabs the current feedly.zip, extracts it then updates our cached header # will growl at you as well # update_feedly() { $CURL --silent --output "$APP_SUPPORT/$FEEDLY_ZIP" "$FEEDLY_URL" $UNZIP -qq -o -d "$APP_SUPPORT" "$APP_SUPPORT/$FEEDLY_ZIP" echo $@ > "$LAST_FEEDLY" if [ -f "$GN" ] ; then $GN --message "Feedly Updated" --title "Feedly Updater" fi } # Create our directory if it doesn't exist if [ ! -d "$APP_SUPPORT/" ] ; then mkdir "$APP_SUPPORT" fi # if our Feedly app-support directory is ready and if # curl exists (it should) if [ -f "$CURL" ] ; then # Get a copy of the favicon if we don't already have it if [ ! -f "$FAVICON_LOCAL" ] ; then $CURL --silent --output "$FAVICON_LOCAL" "$FAVICON_URL" fi # Get current last modified date from the online Feedly zip LAST_UPDATED=`$CURL --silent --output - --head "$FEEDLY_URL" | $GREP "Last-Modified"` # if we haven't grabbed Feedly lately if [ ! -f "$LAST_FEEDLY" ] ; then # init when we started the process and "update" feedly update_feedly $LAST_UPDATED else # Get when we last-grabbed feedly" LAST_GRABBED=`cat "$LAST_FEEDLY"` if [ "$LAST_GRABBED" != "$LAST_UPDATED" ] ; then update_feedly $LAST_UPDATED fi fi fi