Skip to content

Instantly share code, notes, and snippets.

@jehiah
Created February 18, 2011 15:49
Show Gist options
  • Save jehiah/833847 to your computer and use it in GitHub Desktop.
Save jehiah/833847 to your computer and use it in GitHub Desktop.
script to download the latest chromium build nightly
#!/bin/sh
## this is a quick and dirty script to automagically install the latest chromium build on OSX 10.5
## you can set this up as a nightly cron job, or run manually from the command line
# USAGE:
# save script to your home directory aka /Users/$USER/
# open up a command prompt (aka /Applications/Utilities/Terminal)
# run manually from the command line whenever you want the most recent chromium build
# $ sh get_latest_chromium.sh
# start it as a nightly task (runs at 1am or edit the plist below)
# $ sh get_latest_chromium.sh --start
# stop it as a nightly task
# $ sh get_latest_chromium.sh --stop
if [ "$1" == "--start" ]; then
echo "loading scheduled task"
cat >~/Library/LaunchAgents/chromium_update.plist <<-EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>cz.jehiah.scripts.download-nightly-chromium-build</string>
<key>ProgramArguments</key>
<array>
<string>/Users/$USER/get_latest_chromium.sh</string>
</array>
<key>LowPriorityIO</key>
<true/>
<key>UserName</key>
<string>$USER</string>
<key>Nice</key>
<integer>1</integer>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>4</integer>
<key>Minute</key>
<integer>0</integer>
</dict>
</dict>
</plist>
EOF
launchctl load ~/Library/LaunchAgents/chromium_update.plist
exit 0;
fi
if [ "$1" == "--stop" ]; then
echo "unloading scheduled task"
launchctl unload ~/Library/LaunchAgents/chromium_update.plist
exit 0;
fi
function getRunningPids {
ps auxww | grep Chromium.app | grep -v grep | cut -d ' ' -f 2
}
LATEST=`curl --silent http://commondatastorage.googleapis.com/chromium-browser-snapshots/Mac/LAST_CHANGE`;
echo "latest build is $LATEST"
cd /tmp;
echo "switching to `pwd`"
echo "downloading ==> http://commondatastorage.googleapis.com/chromium-browser-snapshots/Mac/$LATEST/chrome-mac.zip";
curl --silent -L -O "http://commondatastorage.googleapis.com/chromium-browser-snapshots/Mac/$LATEST/chrome-mac.zip";
echo "unzipping chrome-mac.zip"
unzip -q chrome-mac.zip;
PIDS=`getRunningPids`
if [ ! -z "$PIDS" ]; then
echo "stopping Chromium -- killing " $PIDS
echo $PIDS | xargs kill > /dev/null 2>&1
sleep 5s
fi
if [ -d /Applications/Chromium.app ] ; then
echo "removing old Chromium in /Applications"
rm -rf /Applications/Chromium.app
fi
echo "moving new version to /Applications"
mv chrome-mac/Chromium.app /Applications/
rm -rf chrome-mac
rm chrome-mac.zip
if [ ! -z "$PIDS" ]; then
echo "staring Chromium"
open /Applications/Chromium.app
fi
echo "done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment