-
-
Save jmbeauford/af6127bd5035d06f64d4ba113c2eeaa0 to your computer and use it in GitHub Desktop.
Chromium Updater
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
# Chromium cli wrapper | |
CHROMIUM_HOME=/Applications/Chromium.app/Contents | |
ROOT_URL=https://commondatastorage.googleapis.com/chromium-browser-continuous/Mac | |
DOWNLOAD_URL=https://download-chromium.appspot.com/dl/Mac | |
function chromium_current { | |
ack -A1 SCMRevision $CHROMIUM_HOME/Info.plist | ack '<string>(.+)</string>' --output '$1' | |
} | |
function chromium_etag { | |
grep ^ETag $CHROMIUM_HOME/LastHeaders | awk '{print $2}' | |
} | |
function chromium_latest { | |
curl -s $ROOT_URL/LAST_CHANGE | |
} | |
function chromium_quit { | |
osascript -e 'tell application "Chromium" to quit' 2>/dev/null | |
} | |
function chromium_update { | |
# Based on http://tcrn.ch/zZYFNq | |
DEST="/Applications/Chromium.app" | |
TMP_ZIP="/tmp/chrome-mac.zip" | |
TMP_HEAD="/tmp/LastHeaders" | |
curl -Lo $TMP_ZIP -D $TMP_HEAD $DOWNLOAD_URL -H "If-None-Match: $(chromium_etag)" | |
if [[ $(grep ^HTTP $TMP_HEAD) == *"304 Not Modified"* ]]; then | |
echo "You're up-to-date!" | |
else | |
unzip -q /tmp/chrome-mac -d /tmp/ | |
chromium_quit | |
if [ -d $DEST ]; then | |
mv $DEST/ ~/.Trash/ | |
fi | |
mv /tmp/chrome-mac/Chromium.app/ $DEST/ | |
mv $TMP_HEAD $CHROMIUM_HOME/ | |
rm -rf $TMP_ZIP /tmp/chrome-mac $TMP_HEAD | |
open $DEST | |
fi | |
} | |
case $1 in | |
update) chromium_update;; | |
version) chromium_current;; | |
latest) chromium_latest;; | |
etag) chromium_etag;; | |
*) $CHROMIUM_HOME/MacOS/Chromium $@;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment