-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·241 lines (202 loc) · 6.05 KB
/
setup.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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
#!/bin/bash
# install file for customization scripts
# can be run with options install and/or uninstall
PWD=$(pwd)
HOME=~
BACKUP=$PWD/uninstall_files
DEPENDS=$'vim-nox\n'
DEPENDS+=$'clang\n'
DEPENDS+=$'vim-youcompleteme\n'
DEPENDS+=$'vim-snippets\n'
DEPENDS+=$'vim-snipmate\n'
DEPENDS+=$'vim-scripts\n'
DEPENDS+=$'fonts-powerline\n'
#DEPENDS+=$'powerline\n'
DEPENDS+=$'vim-pathogen\n'
DEPENDS+=$'vim-addon-manager'
SUDO='su -c'
function main(){
if [ $# -ne 1 ]; then
echo "Error, expects exactly parameter of install or uninstall."
exit
fi
if [ $1 == "install" ]; then
install
elif [ $1 == "uninstall" ]; then
uninstall
elif [ $1 == "test" ]; then
installBundle vim-airline
else
echo "Error, unknown parameter $1"
fi
}
function install(){
echo "Running installation."
mkdir -p $BACKUP || exit 1;
echo "Installing dependecies."
installDepends
vim-addon-manager install youcompleteme doxygen-toolkit pathogen || exit 1;
echo "Pulling all git submodules."
git submodule update --init --recursive || exit 1;
echo "Installing individual files."
installFile .profile
installFile .tmux.conf
installFile .vimrc
installFile .bash_aliases
installFile syntax/c.vim .vim/syntax/
installFile syntax/cpp.vim .vim/syntax/
installFile syntax/javascript.vim .vim/syntax/
installFile tmx bin/
installFile topProcs bin/
echo "Installing powerline font support."
installFile bundle/powerline/font/PowerlineSymbols.otf .fonts/
installFile bundle/powerline/font/10-powerline-symbols.conf .config/fontconfig/conf.d/
echo "Installing vim bundles."
installBundle vim-javascript-syntax
installBundle vim-colors-solarized
installBundle vim-airline
installBundle vim-fugitive
installBundle nerdtree
installBundle nerdtree-git-plugin
echo "Updating font cache."
eval "$SUDO \"fc-cache -vf ~/.fonts\"" || exit 1;
echo
echo "Action succesfully applied"
}
function uninstall(){
echo "Running uninstallation"
echo "Uninstalling individual files."
uninstallFile .profile
uninstallFile .tmux.conf
uninstallFile .vimrc
uninstallFile .bash_aliases
uninstallFile syntax/c.vim .vim/syntax/
uninstallFile syntax/cpp.vim .vim/syntax/
uninstallFile syntax/javascript.vim .vim/syntax/
uninstallFile tmx bin/
uninstallFile topProcs bin/
echo "Uninstalling powerline font support."
uninstallFile bundle/powerline/font/PowerlineSymbols.otf .fonts/
uninstallFile bundle/powerline/font/10-powerline-symbols.conf .config/fontconfig/conf.d/
echo "Uninstalling vim bundles."
uninstallBundle vim-javascript-syntax
uninstallBundle vim-colors-solarized
uninstallBundle vim-airline
uninstallBundle vim-fugitive
uninstallBundle nerdtree
uninstallBundle nerdtree-git-plugin
echo "Updating font cache."
eval "$SUDO \"fc-cache -vf ~/.fonts\"" || exit 1;
echo
echo Note that dependecies installed through apt-get and vim-addon-manager are not automatically removed.
echo
echo apt-get :
echo "$DEPENDS"
echo
echo vim-addon-manager :
echo youcompleteme doxygen-toolkit
echo
echo Action succesfully applied
}
function backupFile(){
echo "Saving a backup copy of $1"
mv $1 $BACKUP/$(basename $1) || exit 1;
}
function restoreFile(){
FN=$BACKUP/$(basename $1)
if [ -e $FN ]; then
echo "Restoring backed up copy of $1"
mv $FN $1 || exit 1;
else
echo "No backed up copy of $1"
fi
}
function installFile(){
SRC=$PWD/$1
DSTDIR=$HOME/$2
DST=$DSTDIR$(basename $1)
echo
echo "Attempting to install file \"$SRC\" to \"$DST\""
# create destination dir if it does not exist
mkdir -p $DSTDIR || exit 1;
if [ ! -e $SRC ]; then
echo "Error, \"$SRC\" does not exist, upstream may have changed something."
exit 1;
fi
if [ -h $DST ]; then
echo "Symlink detected, updating it."
rm $DST || exit 1;
elif [ -e $DST ]; then
echo "File already exists."
backupFile $DST
fi
ln -s $SRC $DST || exit 1
}
function installBundle(){
SRC=$PWD/bundle/$1
DSTDIR=$HOME/.vim/bundle
DST=$DSTDIR/$1
echo
echo "Installing bundle $1."
mkdir -p $DSTDIR || exit 1;
if [ -h $DST ]; then
echo "Symlink detected, updating it."
rm $DST || exit 1;
elif [ -e $DST ]; then
echo "Error, regular file with same name detected in bundle directory."
exit 1;
fi
ln -s $SRC $DST || exit 1
}
function uninstallBundle(){
SRC=$PWD/bundle/$1
DSTDIR=$HOME/.vim/bundle
DST=$DSTDIR/$1
echo
echo "Uninstalling bundle $1."
if [ -h $DST ]; then
echo "Symlink detected, removing it."
rm $DST
elif [ -e $DST ]; then
echo "Regular file detected, leaving it alone."
else
echo "Nothing to be done."
fi
}
function uninstallFile(){
SRC=$PWD/$1
DSTDIR=$HOME/$2
DST=$DSTDIR$(basename $1)
echo
echo "Attempting to uninstall file $SRC from $DST"
if [ -h $DST ]; then
echo "Symlink detected, removing it."
rm $DST
restoreFile $DST
elif [ -e $DST ]; then
echo "Regular file detected, doing nothing."
else
restoreFile $DST
fi
}
function installDepends()
{
echo
echo "Installing missing dependencies, sudo will be needed."
INSTALLED=$(dpkg --get-selections | grep -v deinstall | cut -f1)
while read -r line; do
if [ $(echo $INSTALLED | grep $line | wc -l) -ne 0 ]; then
echo "$line already installed."
DEPENDS=$(echo "$DEPENDS" | grep -v $line)
fi
done <<< "$DEPENDS"
if [ -z "$DEPENDS" ]; then
echo "All libraries are already installed."
else
eval "$SUDO \"apt-get install -y $(echo "$DEPENDS" | tr '\n' ' ')\"" || exit 1;
fi
}
main $@
#ln -s /usr/lib/x86_64-linux-gnu/libclang.so.1 /usr/lib/x86_64-linux-gnu/libclang.so
#sudo apt-get install vim-scripts vim-youcompleteme
#vim-addon-manager install youcompleteme doxygen-toolkit