Last active
December 16, 2015 19:39
-
-
Save akatrevorjay/5486997 to your computer and use it in GitHub Desktop.
Chromium Nightly Updater
This file contains 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 -exv | |
# __________________________ | |
# chromium-update-nightly.sh | |
# | |
# Simple updater that keeps track of partial downloads and if an update is even needed. | |
# | |
# ~trevorj 043013 | |
# | |
fn="$HOME/Downloads/chrome-linux-latest.zip" | |
dest="$HOME/.local" | |
base_url="http://commondatastorage.googleapis.com/chromium-browser-continuous/Linux_x64" | |
chrome_sandbox="$dest/chrome-linux/chrome_sandbox" | |
function e { echo "[$0]" "$@"; } | |
function debug { [[ -z "$DEBUG" ]] || e "$@"; } | |
function error { e "$@" >&2; } | |
function death { error "$@"; exit 1; } | |
fn_installed="${fn%.zip}-installed.zip" | |
fn_installed_idx="$dest/chrome-linux/.index" | |
[[ ! -f "$fn_installed_idx" ]] \ | |
|| idx_installed=$(cat "$fn_installed_idx") | |
fn_idx="${fn%.zip}.index" | |
idx=$(wget -q -O - "$base_url/LAST_CHANGE") | |
test -n "$idx" | |
[[ "$idx" != "$idx_installed" ]] \ | |
|| death "The version currently installed is up to date (latest=$idx installed=$idx_installed)" | |
fn_partial="$fn.partial" | |
fn_partial_idx="${fn_partial%.zip}.index" | |
[[ ! -f "$fn_partial" && ! -f "$fn_partial_idx" ]] \ | |
|| idx_partial=$(cat "$fn_partial_idx") | |
[[ "$idx" == "$idx_partial" ]] \ | |
|| rm -f "$fn_partial" | |
echo "$idx" > "$fn_partial_idx" | |
wget -c -O "$fn_partial" "$base_url/$idx/chrome-linux.zip" | |
mv "$fn_partial" "$fn" | |
mv "$fn_partial_idx" "$fn_idx" | |
test -d "$dest" \ | |
|| death "Destination directory does not exist?" | |
unzip -o -d "$dest" "$fn" | |
mv "$fn" "$fn_installed" | |
mv "$fn_idx" "$fn_installed_idx" | |
## | |
## Fix chrome sandbox setuid | |
## | |
# Sandbox must be setuid and such, so let it be, let it be | |
sudo chown root:root "$chrome_sandbox" | |
sudo chmod 4755 "$chrome_sandbox" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment