home · contact · privacy
Improve automatic go setup in postinstall script.
[config] / setup_go.sh
1 #!/bin/sh
2
3 set -e
4 set -x
5
6 url=$1
7 user=plom
8 users_home=`su $user -s /bin/sh -c 'echo ~'`
9
10 ensure_line() {
11     add_string="$1"
12     file="$2"
13     test=`grep "$add_string" "$file" | wc -l`
14     if [ $test -lt 1 ]; then
15         echo "$add_string" >> "$file"
16     fi
17 }
18
19 filename=temp_golang_binary
20
21 if [ "$url" = "" ]; then
22     echo 'Need URL of current go package'
23     exit 1
24 fi
25 rm -rf /usr/local/go
26 apt-get -y install wget
27 wget -O $filename $url
28 tar -C /usr/local -xzf $filename
29 rm $filename
30 ensure_line 'export PATH=$PATH:/usr/local/go/bin' $users_home/.shinit_add
31 ensure_line 'export GOPATH=~/gopath' $users_home/.shinit_add
32 apt-get -y install vim-pathogen
33 rm -rf $users_home/.vim/bundle/vim-go
34 su $user -s 'git clone https://github.com/fatih/vim-go.git ~/.vim/bundle/vim-go'
35 ensure_line 'source ~/.vimrc_vimgo' $users_home/.vimrc_add
36 cat << EOF > $users_home/.vimrc_vimgo
37 " vim-go: Make vim-go run.
38 call pathogen#infect()
39 let g:go_disable_autoinstall = 0
40 " vim-go: Highlight
41 let g:go_highlight_functions = 1
42 let g:go_highlight_methods = 1
43 let g:go_highlight_structs = 1
44 let g:go_highlight_operators = 1
45 let g:go_highlight_build_constraints = 1
46 EOF
47 chown $user $users_home/.vimrc_vimgo
48 chgrp $user $users_home/.vimrc_vimgo