-
Notifications
You must be signed in to change notification settings - Fork 1
/
provision.sh
executable file
·158 lines (121 loc) · 3.87 KB
/
provision.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#!/usr/bin/env bash
set -e
USER=vagrant
PASSWORD=vagrant
export CODE_DIR=$HOME/code
export GOPATH=$CODE_DIR/golang
export GOROOT=$CODE_DIR/go
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH
function apt_get_update() {
# We only want to do this on the very first run.
if [ ! -f $HOME/.apt_get_last_updated ]; then
sudo apt-get update
date "+%s" > $HOME/.apt_get_last_updated
fi
}
function clone_and_link_dotfiles() {
sudo apt-get install -y git
mkdir -p $CODE_DIR
if [ ! -d $CODE_DIR/dotfiles ]; then
git clone git://github.com/leocassarani/dotfiles.git $CODE_DIR/dotfiles
cd $CODE_DIR/dotfiles
git submodule init
git submodule update
# Change the remote to one we can push to.
git remote set-url origin "[email protected]:leocassarani/dotfiles.git"
fi
if [ ! -f ~/.gitconfig ]; then ln -s $CODE_DIR/dotfiles/gitconfig ~/.gitconfig; fi
if [ ! -f ~/.gitignore_global ]; then ln -s $CODE_DIR/dotfiles/gitignore_global ~/.gitignore_global; fi
if [ ! -f ~/.tmux.conf ]; then ln -s $CODE_DIR/dotfiles/tmux.conf ~/.tmux.conf; fi
if [ ! -f ~/.vimrc ]; then ln -s $CODE_DIR/dotfiles/vimrc ~/.vimrc; fi
if [ ! -d ~/.vim ]; then ln -s $CODE_DIR/dotfiles/.vim ~/.vim; fi
if [ ! -f ~/.zshrc ]; then ln -s $CODE_DIR/dotfiles/zshrc ~/.zshrc; fi
}
function install_zsh() {
sudo apt-get install -y git zsh
if [ ! -d ~/.oh-my-zsh ]; then
git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
echo $PASSWORD | chsh -s /bin/zsh
fi
}
function install_vim() {
sudo apt-get install -y python-software-properties
if [ ! -f /etc/apt/sources.list.d/fcwu-tw-ppa-precise.list ]; then
sudo add-apt-repository ppa:fcwu-tw/ppa
sudo apt-get update
fi
sudo apt-get install -y vim
}
function install_tmux() {
sudo apt-get install -y python-software-properties
if [ ! -f /etc/apt/sources.list.d/pi-rho-dev-precise.list ]; then
sudo add-apt-repository ppa:pi-rho/dev
sudo apt-get update
fi
sudo apt-get install -y tmux
}
function install_dev_tools() {
sudo apt-get install -y curl wget exuberant-ctags htop
install_the_silver_searcher
}
function install_the_silver_searcher() {
sudo apt-get install -y automake make pkg-config libpcre3-dev zlib1g-dev liblzma-dev
AGDIR=/tmp/the_silver_searcher
if [ ! $(which ag) ]; then
git clone git://github.com/ggreer/the_silver_searcher.git $AGDIR
cd $AGDIR
./build.sh
sudo make install
rm -rf $AGDIR
cd
fi
}
function install_go() {
sudo apt-get install -y mercurial
if [ ! $(which go) ]; then
if [ ! -d $GOROOT ]; then
hg clone -u release https://code.google.com/p/go $GOROOT
fi
cd $GOROOT/src
./all.bash
fi
mkdir -p $GOPATH
go get code.google.com/p/go.tools/cmd/goimports
go get github.com/golang/lint/golint
go get golang.org/x/tools/cmd/vet
}
function install_ruby() {
sudo apt-get install -y python-software-properties
if [ ! -f /etc/apt/sources.list.d/brightbox-ruby-ng-precise.list ]; then
sudo add-apt-repository ppa:brightbox/ruby-ng
sudo apt-get update
fi
sudo apt-get install -y ruby2.1
}
function install_haskell() {
sudo apt-get install -y libgmp10 libgmp-dev
URL=https://www.haskell.org/platform/download/2014.2.0.0/haskell-platform-2014.2.0.0-unknown-linux-x86_64.tar.gz
TARFILE=haskell-platform-2014.2.0.0-unknown-linux-x86_64.tar.gz
if [ ! $(which ghc) ]; then
if [ ! -f /tmp/$TARFILE ]; then
cd /tmp
wget --no-verbose $URL
fi
cd /
sudo tar xf /tmp/$TARFILE
sudo /usr/local/haskell/ghc-7.8.3-x86_64/bin/activate-hs
rm /tmp/$TARFILE
fi
}
function main() {
apt_get_update
clone_and_link_dotfiles
install_zsh
install_vim
install_tmux
install_dev_tools
install_go
install_ruby
install_haskell
}
main