Skip to content

Instantly share code, notes, and snippets.

@tcjennings
Last active December 11, 2016 05:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tcjennings/7a4467f879a4e19ef4068f15233c2bf7 to your computer and use it in GitHub Desktop.
Save tcjennings/7a4467f879a4e19ef4068f15233c2bf7 to your computer and use it in GitHub Desktop.
Install Node and Golang on Raspberry Pi Raspian; Build Latest Grafana
#!/bin/bash
GOVER=1.7.4
GRAFANA_VER=4.0.2
sudo apt-get update
sudo apt-get install -y ruby ruby-dev adduser libfontconfig
sudo gem install fpm
mkdir -p ~/src/go
sudo mkdir /opt/local/go
cat << EOF >> ~/.profile
export PATH="$PATH:/opt/local/go/bin"
export GOHOME=$HOME
export GOROOT=/opt/local/go
export GOPATH="$HOME/src/go"
EOF
. ~/.profile
cd $HOME
if [[ ! -f /usr/local/bin/node ]]; then
curl -O https://node-arm.herokuapp.com/node_latest_armhf.deb
sudo dpkg -i $HOME/node_latest_armhf.deb
rm $HOME/node_latest_armhf.deb
fi
if [[ ! -f /usr/local/bin/phantomjs ]]; then
sudo tee /etc/apt/sources.list.d/wheezy.list > /dev/null << EOF
deb http://mirrordirector.raspbian.org/raspbian/ wheezy main contrib non-free
EOF
sudo apt-get update
sudo apt-get install -y libicu48 fontconfig libjpeg8
curl https://raw.githubusercontent.com/timstanley1985/phantomjs-linux-armv6l/master/phantomjs-2.1.1-linux-armv6l.tar.gz \
| sudo tar xzf - -C /usr/local --strip-components=1 --no-same-permissions --no-same-owner
fi
pushd /opt/local
curl https://storage.googleapis.com/golang/go${GOVER}.linux-armv6l.tar.gz | sudo tar xzf -
sudo mv ./go ./go_${GOVER}
sudo ln -s /opt/local/go_${GOVER} /opt/local/go
popd
pushd $GOPATH
go get github.com/grafana/grafana
popd
pushd $GOPATH/src/github.com/grafana/grafana/
git checkout v${GRAFANA_VER}
go run build.go setup
npm install
go run build.go build
go run build.go pkg-deb
popd
sudo apt-get clean
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment