Skip to content

Instantly share code, notes, and snippets.

@savsgio
Last active August 21, 2018 06:54
Show Gist options
  • Save savsgio/9a07699ccee8d418943dc619697ddef7 to your computer and use it in GitHub Desktop.
Save savsgio/9a07699ccee8d418943dc619697ddef7 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
GOVERSION="1.10.3"
JAPOVERSION="2.0.0"
WHOAMI=$(whoami)
GOBIN_IS_SET=$(cat /etc/environment | grep "/usr/local/go/bin:/usr/local/go/deps/bin" | wc -l)
GOPATH_IS_SET=$(cat /etc/environment | grep GOPATH | wc -l)
if [ ${WHOAMI} != "root" ]; then
echo "------------------------------------"
echo "##### Execute script with root #####"
echo "------------------------------------"
exit 0
fi
echo "Installing build-essential..."
apt-get update
apt-get install -y build-essential
echo "Installing Go ${GOVERSION} ..."
cd /usr/src
if [ ! -d /usr/local/go ]; then
wget https://dl.google.com/go/go${GOVERSION}.linux-amd64.tar.gz
tar xzf go${GOVERSION}.linux-amd64.tar.gz -C /usr/local
else
echo "Go is already installed..."
fi
if [ ! -d /usr/local/go/deps ]; then
mkdir -p /usr/local/go/deps
mkdir -p /usr/local/go/deps/bin
fi
chown root:root -R /usr/local/go
if [ ${GOBIN_IS_SET} = 0 ]; then
echo "PATH=${PATH}:/usr/local/go/bin:/usr/local/go/deps/bin" > /etc/environment
fi
if [ ${GOPATH_IS_SET} = 0 ]; then
echo "GOPATH=/usr/local/go/deps " >> /etc/environment
fi
. /etc/environment
echo "Installing dep..."
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
echo "Installing japo..."
wget https://github.com/savsgio/japo/archive/v${JAPOVERSION}.tar.gz
tar xvf v${JAPOVERSION}.tar.gz -C .
cd japo-${JAPOVERSION}/
make
make install
echo "Installing japo daemon..."
make daemon
echo "\nRemeber customize '/etc/japo.yml' with your own configuration...\n"
echo "Enjoy..."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment