-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap.sh
executable file
·86 lines (79 loc) · 2.23 KB
/
bootstrap.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/bash
#
# Options:
#
# -s: Build Go from source. If not provided, then just use the package.
#
set -e
set -x
while getopts s o
do
case "$o" in
s) build_from_source=1;;
[?]) echo "Usage: $0 [-s] " >&2
exit 1;;
esac
done
if [ ! -x /usr/bin/gcc ]; then
echo "Installing gcc"
sudo apt-get --no-install-recommends -y install --quiet gcc
echo "gcc installed"
fi
if [ ! -x /usr/bin/git ]; then
echo "Installing git"
sudo apt-get --no-install-recommends -y install --quiet git
echo "git installed"
fi
if [ ! -x /usr/bin/go ]; then
echo "Installing go"
sudo apt-get --no-install-recommends -y install --quiet golang
echo "go installed"
fi
if [ ! -x /usr/bin/lsb_release ]; then
echo "Installing lsb_release"
sudo apt-get --no-install-recommends -y install --quiet lsb-release
echo "lsb_release installed"
fi
if [ ! -x /usr/bin/ssh ]; then
echo "Installing ssh"
sudo apt-get --no-install-recommends -y install --quiet ssh
echo "ssh installed"
fi
if [ ! -d /usr/share/ca-certificates ]; then
echo "Installing ca-certificates"
sudo apt-get --no-install-recommends -y install --quiet ca-certificates
echo "ca-certificates installed"
fi
if [[ ${build_from_source} -eq 1 ]] && [ ! -e ~/src/go/bin/go ]; then
if [ ! -e ~/src/go ]; then
git clone https://go.googlesource.com/go ~/src/go
fi
cd ~/src/go
latest=$(git describe --tags `git rev-list --tags --max-count=1`)
echo "Building go version ${latest}"
git checkout ${latest}
cd ~/src/go/src
./all.bash
fi
PATH="${HOME}/go/bin:${PATH}"
DOTFILES_DIR=~/go/src/github.com/minusnine/dotfiles
DOTFILES_URL="https://github.com/minusnine/dotfiles"
if [ ! -e ${DOTFILES_DIR} ]; then
echo "Cloning dotfiles to $DOTFILES_DIR"
git clone ${DOTFILES_URL} ${DOTFILES_DIR}
elif [ ! -e ${DOTFILES_DIR}/.git ]; then
echo "Pulling dotfiles in $DOTFILES_DIR"
mkdir -p ${DOTFILES_DIR}
git -C ${DOTFILES_DIR} init
git -C ${DOTFILES_DIR} remote add origin ${DOTFILES_URL} || /bin/true
git -C ${DOTFILES_DIR} pull
fi
if [ ! -e ~/src/dotfiles ]; then
[ -e ~/src ] || mkdir ~/src
ln -sf $DOTFILES_DIR ~/src/dotfiles
fi
cd $DOTFILES_DIR
export GOPATH=${HOME}/go
go get -t ./...
sudo GOPATH=$GOPATH go run ${DOTFILES_DIR}/install.go --alsologtostderr --real_user=$USER
go run ${DOTFILES_DIR}/install.go --alsologtostderr