Skip to content

Instantly share code, notes, and snippets.

@miketaylr
Forked from sh1mmer/README
Created February 10, 2010 00:21
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 miketaylr/299855 to your computer and use it in GitHub Desktop.
Save miketaylr/299855 to your computer and use it in GitHub Desktop.
This script updates to Chromium nightly. You can run it manually, but I run it using cron.
If you run it using cron remember that it _will quit_ your running Chromium so make sure you have it set to save tabs if you want them.
In order to install it with cron run:
crontab -e
Add the line:
0 0 * * * bash /Users/croucher/bin/chromium-nightly.sh
I keep my script in ~/bin/ but you should update to the appropriate command.
You can also alter the first two columns to reflect when you want to update. Mine is set to 0 hours, 0 minutes (midnight) but you can set any time on a 24 hour clock.
#!/bin/sh
# Get current build for Chromium on Mac.
#
# @version 2009-05-22
# @authors sh1mmer on Twitter.com
# Tlalox on macosxhints.com
# robg on macosxhints.com
# @todo Nothing yet
# setup ------------------------------------------------------------------------
tempDir="/tmp/`whoami`/chrome-nightly/";
baseURL="http://build.chromium.org/buildbot/snapshots/chromium-rel-mac/";
baseName="chrome-mac";
baseExt="zip";
appName="Chromium.app";
appDir="/Applications";
version=~/.CURRENT_CHROME;
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
function checkForErrors {
if [ "$?" != "0" ]; then
echo "Unkown error (see above for help)!";
exit 3;
fi
}
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
echo "Setup...";
mkdir -p "$tempDir";
cd "$tempDir";
checkForErrors;
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
echo "Checking current version...";
touch $version
currentVersion=`cat $version`;
latestVersion=`curl -s $baseURL/LATEST`;
checkForErrors;
echo " * your/latest build: $currentVersion / $latestVersion";
if [ "$currentVersion" == "$latestVersion" ]; then
echo " * build $currentVersion is the latest one.";
exit 1;
fi
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
echo "Downloading and unpacking...";
chromePID=`ps wwaux|grep -v grep|grep "$appName"|awk '{print $2}'`;
curl -o $baseName.$baseExt "$baseURL/$latestVersion/$baseName.$baseExt";
unzip -qo $baseName.$baseExt;
checkForErrors;
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
echo "Installing...";
if [ "$chromePID" != "" ];then
osascript -e '
tell application "System Events"
if exists (some process whose name contains "Chromium") then
tell application "Chromium" to quit
end if
end tell
end run'
fi
cp -r $baseName/$appName $appDir
checkForErrors;
echo $latestVersion > $version;
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
osascript -e 'tell application "Chromium"
activate
end tell'
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
echo "Done. You're now running build $latestVersion";
# ------------------------------------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment