diff --git a/run.sh b/run.sh index 2d5f026..6c3bf34 100755 --- a/run.sh +++ b/run.sh @@ -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 & diff --git a/update-and-run.sh b/update-and-run.sh index 93673ed..cbff49e 100755 --- a/update-and-run.sh +++ b/update-and-run.sh @@ -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 diff --git a/update.sh b/update.sh index 6730185..a6cb36c 100755 --- a/update.sh +++ b/update.sh @@ -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"