Skip to content

Instantly share code, notes, and snippets.

@npostavs
Created September 28, 2013 20:55
Show Gist options
  • Save npostavs/6746448 to your computer and use it in GitHub Desktop.
Save npostavs/6746448 to your computer and use it in GitHub Desktop.
Goread Installation/Update
#!/bin/bash
install_pkgs() {
sudo apt-get install "$@"
}
install_go_engine() {
local prefix=http://googleappengine.googlecode.com/files/go_appengine_sdk
local os=linux
local -A arches=([x86_64]=amd64 [i386]=386)
local arch=${arches[$(uname -m)]}
local version=1.8.3
local cksum=a50fb720b40e35306f0fdf8e1f70ff238778cfd4
local url="${prefix}_${os}_${arch}-${version}.zip"
local zipfile=${url##*/}
wget "$url"
if which sha1sum >/dev/null ; then
{ echo "$cksum *$zipfile" | sha1sum -c ; } || exit $?
fi
unzip "$zipfile" -d "$go_engine_prefix"
}
install() {
# platform dependencies
install_pkgs python2.7 git mercurial
# platform
install_go_engine
# app dependencies
$godir/go get -d github.com/$user/goread/goapp
# app
cd $GOPATH/src/github.com/$user/goread
## go get does checkout origin/master so we have detached HEAD
git checkout master # reattach HEAD
cp app.sample.yaml app.yaml
(cd goapp && cp settings.go.dist settings.go)
}
go_engine_prefix=$HOME
godir=$go_engine_prefix/go_appengine
: ${GOPATH:=$godir/gopath}
export GOPATH
user=mjibson
case $1 in
(install) install;;
(run) $godir/dev_appserver.py app.yaml;;
(deps) $godir/go get -u github.com/mjibson/goread/goapp;;
(upload) $godir/appcfg.py update .;;
(rollback) $godir/appcfg.py rollback .;;
(*) echo "I don't know how to '$1'" 1>&2
echo "Usage: $0 <install|run|deps|upload|rollback>" 1>&2
exit 1;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment