Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions run.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#! /bin/bash
#!/bin/sh

BASEDIR=$(dirname $0)
BASEDIR="$(dirname $(realpath $(readlink -f $0)))"

$BASEDIR/latest/chrome --user-data-dir="$BASEDIR/user-data-dir" $* &> /dev/null &
8 changes: 5 additions & 3 deletions update-and-run.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#! /bin/bash
cd $(dirname $0)
./update.sh && ./run.sh
#!/bin/sh

BASEDIR="$(dirname $(realpath $(readlink -f $0)))"

$BASEDIR/update.sh && $BASEDIR/run.sh
64 changes: 47 additions & 17 deletions update.sh
Original file line number Diff line number Diff line change
@@ -1,31 +1,61 @@
#! /bin/bash

cd $(dirname $0)
#!/bin/sh

BASEDIR="$(dirname $(realpath $(readlink -f $0)))"

web() {
local list="wget curl"
for item in $list;
do
if [ -z $(command -v $item) ]; then
echo $list | sed "s/$item//g"
fi
done
}

dl() {
case $(web) in
*wget*) wget -q --show-progress -O $@;;
*curl*) curl -#L -o $@;;
esac
}

out() {
case $(web) in
*curl*) curl -sL $@;;
*wget*) wget -qO - $@;;
esac
}

TRUNK="snapshots"
if [ -n "$1" ]; then
OPT="$1"
shift
case "$OPT" in
snapshots|s) TRUNK="snapshots";;
continuous|c) TRUNK="continuous";;
esac
fi

LASTCHANGE_URL="https://www.googleapis.com/download/storage/v1/b/chromium-browser-snapshots/o/Linux_x64%2FLAST_CHANGE?alt=media"
LASTCHANGE_URL="https://www.googleapis.com/download/storage/v1/b/chromium-browser-$TRUNK/o/Linux_x64%2FLAST_CHANGE?alt=media"

REVISION=$(curl -s -S $LASTCHANGE_URL)
REVISION=$(out $LASTCHANGE_URL)

echo "latest revision is $REVISION"

if [ -d $REVISION ] ; then
if [ -d $BASEDIR/$REVISION ] ; then
echo "already have latest version"
exit
fi

ZIP_URL="https://www.googleapis.com/download/storage/v1/b/chromium-browser-snapshots/o/Linux_x64%2F$REVISION%2Fchrome-linux.zip?alt=media"
ZIP_URL="https://www.googleapis.com/download/storage/v1/b/chromium-browser-$TRUNK/o/Linux_x64%2F$REVISION%2Fchrome-linux.zip?alt=media"

ZIP_FILE="${REVISION}-chrome-linux.zip"
ZIP_FILE="chrome-linux-${REVISION}.zip"

echo "fetching $ZIP_URL"

rm -rf $REVISION
mkdir $REVISION
pushd $REVISION
curl -# $ZIP_URL > $ZIP_FILE
dl "$BASEDIR/$ZIP_FILE" "$ZIP_URL"
echo "unzipping.."
unzip $ZIP_FILE
popd
rm -f ./latest
ln -s $REVISION/chrome-linux/ ./latest

unzip "$BASEDIR/$ZIP_FILE" -d "$BASEDIR"
mv "$BASEDIR/chrome-linux" "$BASEDIR/$REVISION"
rm -f "$BASEDIR/latest" "$BASEDIR/$ZIP_FILE"
ln -s "$BASEDIR/$REVISION" "$BASEDIR/latest"