-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·126 lines (105 loc) · 2.77 KB
/
install.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
#!/bin/bash
ARCH=""
if [ $# -eq 1 ]; then
if [ "X$1" == "Xcentos" -o "X$1" == "Xubuntu" ]; then
ARCH=$1
else
echo "parameter error"
fi
fi
ROOT=$(cd "$(dirname "$0")"; pwd)
PLUGINS="$ROOT/plugins"
[ -d $ROOT/plugins ] && rm -rf $ROOT/plugins
tar -xf $ROOT/plugins.tar.gz
tar -xf $ROOT/gobinaries.tar.gz
function load_vim()
{
rm -rf /root/.vim
cp -r "$PLUGINS/vim" /root/.vim
rm -f /root/.vimrc
cp "$ROOT/vimrc" /root/.vimrc
}
# install vim-go dependency pkgs to the default GOPATH '/root/go'
# there are two ways to do it
# 1. execute :GoInstallBinaries in vim editor manually
# 2. unpack the existing(if we already installed) go binaries
# and dependency pkgs, copy it to the GOPATH
# the following function do it in the second way, but correctness
# can not be guaranteed.
# Note that vim-go need vim version greater than 8.1, we should
# install vim to /usr/bin from the source code as the following
# steps:
# 1. git clone https://github.com/newfriday/vim.git
# 2. cd vim
# 3. ./configure --with-features=huge --enable-pythoninterp --prefix /usr
# 4. make -j
# 5. make install
function load_golang()
{
rpm -qi golang
if [ $? -eq 1 ]; then
yum install -y golang
fi
[ -d /root/go ] && rm -rf /root/go
mv $ROOT/go /root/
}
function load_tmux()
{
rm -f /root/.tmux.conf
cp "$ROOT/tmux.conf" /root/.tmux.conf
}
function load_gitconf()
{
[ -f /root/.gitconfig ] || cp "$ROOT/gitconfig" /root/.gitconfig
}
function load_mybash()
{
mkdir -p /usr/bin/mybash
cat /etc/profile | grep mybash
if [ $? -ne 0 ]; then
echo "export PATH=\${PATH}:/usr/bin/mybash" >> /etc/profile
source /etc/profile
fi
chmod +x backup_history.sh
cp -f backup_history.sh /usr/bin/mybash/
cat /etc/crontab | grep mybash
if [ $? -ne 0 ]; then
echo "0 19 * * 6 /usr/bin/mybash/backup_history.sh" >> /etc/crontab
service crond restart > /dev/null 2>&1
fi
}
function config_centos()
{
cp -f "$ROOT/iptables.rules" /etc/sysconfig/iptables.rules
cat /etc/rc.d/rc.local | grep "iptables-restore < /etc/sysconfig/iptables.rules" > /dev/null
if [ $? -ne 0 ]; then
[ -f /etc/rc.d/rc.local ] && \
echo "iptables -F" && \
echo "iptables-restore < /etc/sysconfig/iptables.rules" >> /etc/rc.d/rc.local && \
echo "config iptable rules done"
fi
chmod +x /etc/rc.d/rc.local
[ -f /etc/sysconfig/selinux ] && \
sed -i 's/^SELINUX=enforcing$/SELINUX=disabled/' /etc/sysconfig/selinux && \
echo "config selinux done"
return 0
}
function config_ubuntu()
{
return 0
}
load_vim
load_golang
load_tmux
load_gitconf
load_mybash
# set ENV EDITOR as vim so that git tools can use plugins successfully
export EDITOR=vim
if [ "X$ARCH" == "Xcentos" ]; then
echo "config centos ..."
config_centos
fi
if [ "X$ARCH" == "Xubuntu" ]; then
echo "config ubuntu ..."
config_ubuntu
fi