-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdotsync-yum.sh
executable file
·202 lines (186 loc) · 5.93 KB
/
dotsync-yum.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
#!/bin/bash -e
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/files"
function usage() {
echo "Usage: $0 [-h --help] [-d --download] [-u --upload] [-f --first-time <force>] [-t --test] 1>&2"
exit 1
}
function help() {
echo "-f or --first-time when you want to install everything on a new machine."
echo "-f force or --first-time force when you want to overwrite previous attempts."
echo "-d or --download when you want to sync the dotfiles with the repo."
echo "-u or --upload when you made local changes and want to push them to the repo."
exit 1
}
function testRun() {
echo $@
echo $DIR
}
function firstTime() {
if [[ ${force} == "force" ]]; then
echo 'Forced install.'
fi
sudo git fetch > /dev/null
sudo git pull > /dev/null
for file in $(cat $DIR/../filelist); do
sudo cp -r $DIR/$file $HOME
sudo cp -r $DIR/$file /root/
echo "Copied $DIR/$file to home ($HOME)"
done
mkdir -p $HOME/school
echo "Done copying files to your home ($HOME)."
# Dependencies
sudo yum update
sudo yum groupinstall -y development
sudo yum install -y ruby ruby-devel lua lua-devel luajit ctags git python python-devel python36 python36-devel tcl-devel perl-devel perl-ExtUtils-ParseXS perl-ExtUtils-CBuilder gcc cmake make automake autoconf openssl-devel zlib-devel httpd-devel apr-devel apr-util-devel sqlite-devel https://centos7.iuscommunity.org/ius-release.rpm yum-utils ncurses-devel glibc-static libevent-devel zsh tmux
installRuby
#Install tmux, tmuxinator, zsh, vim80 with youcompleteme plugin
if [[ ! -f /usr/local/bin/tmuxinator || $force == 'force' ]]; then
sudo gem update
sudo gem update --system
sudo gem install tmuxinator else
echo "Already have Tmuxinator installed."
fi
if [[ ! -f /bin/zsh || $force == 'force' ]]; then
#echo "zsh" >> $HOME/.bashrc
:
else
echo "Already have ZSH installed."
fi
if [[ ! -d /usr/local/share/vim/vim81 || $force == 'force' ]]; then
installVim
else
echo "Already have ViM81 installed."
fi
installVundle
chsh -s /bin/zsh root
echo "All done! Please restart your terminal."
}
function download() {
sudo git fetch > /dev/null 2>&1
echo "Fetching."
sudo git pull > /dev/null 2>&1
echo "Pulling."
read -p "Pull all dotfiles?" -n 1 ans
echo
for file in $(cat filelist); do
if [[ $ans =~ ^[YyJj]$ ]]; then
cp -r $DIR/$file $HOME
sudo cp -r $DIR/$file /root/
echo "Copied $DIR/$file to home ($HOME)"
else
read -p "Pull $DIR/$file?" -n 1 -r
echo
if [[ $REPLY =~ ^[YyJj]$ ]]; then
sudo cp -r $DIR/$file $HOME
fi
fi
done
zsh
}
function upload() {
read -p "Push all dotfiles?" -n 1 ans
echo
for file in $(cat filelist); do
if [[ $ans =~ ^[YyJj]$ ]]; then
sudo cp -r $HOME/$file $DIR
echo "Copied $file to $DIR"
else
read -p "Push $HOME/$file?" -n 1 -r
echo
if [[ $REPLY =~ ^[YyJj]$ ]]; then
sudo cp -r $HOME/$file $DIR
fi
fi
done
echo "Copied all dotfiles to $DIR. Now let's commit and push."
sudo git add -A
echo "Added."
sudo git commit -a --allow-empty-message -m '' > /dev/null #2>&1
echo "Committed."
sudo git push > /dev/null #2>&1
echo "Pushed."
}
function installVim() {
# install dependencies
PYTHONCONFIGDIR=$(find /usr/lib64 /usr/lib -iname "config-*" -type d)
echo "Python config dir: ${PYTHONCONFIGDIR}"
#Delete current vim
sudo yum remove -y vim vim-runtime gvim
sudo rm -rf /usr/local/share/vim /usr/local/bin/vim /usr/bin/vim
#Clone vim repo, configure and make
cd ${HOME}
sudo rm -rf vim
git clone https://github.com/vim/vim.git
cd vim
sudo ./configure --with-features=huge \
--enable-multibyte \
--enable-python3interp=yes \
--with-python3-config-dir=${PYTHONCONFIGDIR} \
--enable-gui=gtk2 \
--enable-cscope \
--prefix=/usr/local
make VIMRUNTIMEDIR=/usr/local/share/vim/vim81
#Install that shit
sudo make install
# Cleanup
sudo rm -rf $HOME/vim
echo "All done!"
}
installRuby(){
if [[ ! -f /usr/local/rvm/rubies/ruby-head/bin/ruby && ! -L /usr/bin/ruby ]]; then
echo "Installing latest Ruby and RVM."
curl -sSL https://rvm.io/mpapis.asc | gpg2 --import -
curl -sSL https://rvm.io/pkuczynski.asc | gpg2 --import -
curl -L get.rvm.io | bash -s stable
sudo usermod -a -G rvm root
sudo usermod -a -G rvm ${USER}
source /etc/profile.d/rvm.sh
rvm reload
rvm requirements run
rvm install ruby-head
rm -rf /usr/bin/ruby
ln -s /usr/local/rvm/rubies/ruby-head/bin/ruby /usr/bin/ruby
else
echo "Ruby already installed."
fi
}
installVundle(){
# Install Vundle
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
vim +PluginInstall +qall
$HOME/.vim/bundle/YouCompleteMe/install.py --clang-completer
# Do it all for root as well
#sudo git clone https://github.com/VundleVim/Vundle.vim.git /root/.vim/bundle/Vundle.vim
#sudo su -c "vim +PluginInstall +qall"
#sudo /root/.vim/bundle/YouCompleteMe/install.py --clang-completer
}
if [[ $# == 0 ]]; then usage; fi
while [[ $# > 0 ]]; do
key=$1
case $key in
-d|--download)
download
shift # key
;;
-u|--upload)
upload
shift # key
;;
-f|--first-time)
force=$2
firstTime $force
shift # key
shift # value
;;
-t|--test)
testRun $@
shift $# # key
;;
-h|--help)
help
;;
*)
usage
;;
esac
done