-
Notifications
You must be signed in to change notification settings - Fork 16
/
RQCGY.sh
212 lines (178 loc) · 4.84 KB
/
RQCGY.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
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
clear;
cd /root
rm -f /root/RQCGY.sh
echo -e "\033[33m=========================================================================\033[0m"
echo -e "\033[36m VPN MYSQL and pam_mysql Automatic installation\033[0m"
echo ""
echo -e "\033[32m 版本:常规方式 -- 远程数据库\033[0m"
echo ""
echo -e "\033[32m by 落魄书生\033[0m"
echo -e "\033[35m 请按回车继续开始安装\033[0m"
echo -e "\033[33m==========================================================================\033[0m"
echo "$CopyrightLogo";
read
cd /
echo
echo "设置远程数据库信息"
echo
echo -n " 输入数据库地址:"
read dz
if [ -z $dz ]
then
echo -n " 输入数据库地址:"
read dz
if [ -z $dz]
then
echo " 地址设定失败"
dz=127.0.0.1;
fi
fi
echo -n " 输入数据库端口:"
read dk
if [ -z $dk ]
then
echo -n " 输入数据库端口:"
read dk
if [ -z $dk]
then
echo " 端口设定失败"
dk=3306;
fi
fi
echo -n " 输入数据库管理员:"
read us
if [ -z $us ]
then
echo -n " 输入数据库管理员:"
read us
if [ -z $us]
then
echo " 管理员设定失败"
us=root;
fi
fi
echo -n " 输入数据库密码:"
read ps
if [ -z $ps ]
then
echo -n " 输入数据库密码:"
read ps
if [ -z $ps]
then
echo " 密码设定失败"
ps=root;
fi
fi
echo -n " 是否需要重建数据库(y/n):"
read cj
if [ -z $cj ]
then
echo -n " 是否需要重建数据库(y/n):"
read cj
if [ -z $cj]
then
echo " 设定失败,默认不重建"
cj=n;
fi
fi
yum -y install vixie-cron
yum -y install crontabs
yum -y install openssl openssl-devel cyrus-sasl cyrus-sasl-devel
cd /etc/openvpn/
rm -f server.conf
wget https://github.com/mu228/LPSS/raw/master/cg/server.conf
wget https://github.com/mu228/LPSS/raw/master/openvpn-auth-pam.so
wget https://github.com/mu228/LPSS/raw/master/yc/connect.sh
wget https://github.com/mu228/LPSS/raw/master/yc/disconnect.sh
wget https://github.com/mu228/LPSS/raw/master/yc/test.sh
sed -i 's/127.0.0.1/'$dz'/' /etc/openvpn/connect.sh
sed -i 's/3306/'$dk'/' /etc/openvpn/connect.sh
sed -i 's/127.0.0.1/'$dz'/' /etc/openvpn/disconnect.sh
sed -i 's/3306/'$dk'/' /etc/openvpn/disconnect.sh
sed -i 's/127.0.0.1/'$dz'/' /etc/openvpn/test.sh
sed -i 's/3306/'$dk'/' /etc/openvpn/test.sh
gzexe connect.sh
gzexe disconnect.sh
gzexe test.sh
chmod +x /etc/openvpn/connect.sh
chmod +x /etc/openvpn/disconnect.sh
chmod +x /etc/openvpn/test.sh
rm -f connect.sh~
rm -f disconnect.sh~
rm -f test.sh~
chkconfig crond on
/sbin/service crond restart
cd /etc
wget https://github.com/mu228/LPSS/raw/master/K.sh
chmod 0755 K.sh
sleep 1
echo "40 3 * * * root /etc/openvpn/test.sh" >> crontab
/sbin/service crond restart
./K.sh &
crontab
echo "crontab..."
rm -f /etc/K.sh
sleep 1
echo "pam_mysql安装开始"
yum install -y mysql-devel pam-devel gcc gcc-c++ openssl
sleep 1
echo "pam_mysql下载解压"
wget https://github.com/mu228/LPSS/raw/master/pam_mysql-0.7RC1.tar.gz
tar zxvf pam_mysql-0.7RC1.tar.gz
echo
sleep 1
cd pam_mysql-0.7RC1
echo "文件校验"
sleep 1
./configure –with-openssl
echo
sleep 2
./configure
echo
sleep 3
echo "安装中"
make
make install
ln /lib/security/pam_mysql.* /lib64/security/
cd /etc/pam.d
wget https://github.com/mu228/LPSS/raw/master/yc/openvpn
sed -i 's/127.0.0.1/'$dz'/' /etc/pam.d/openvpn
sed -i 's/3306/'$dk'/' /etc/pam.d/openvpn
cd /home
wget https://github.com/mu228/LPSS/raw/master/vpn.sql
echo "安装 完毕"
echo "重启服务"
/etc/init.d/saslauthd start
mysql -h$dz -P$dk -u$us -p$ps -e "
USE openvpn;
GRANT ALL ON openvpn.* TO 'lpss'@'%' IDENTIFIED BY 'lpss';
"
if [ $cj = 'y' ];then
echo "不重建"
mysql -h$dz -P$dk -u$us -p$ps -e "
CREATE DATABASE openvpn;
USE openvpn;
GRANT ALL ON openvpn.* TO 'lpss'@'%' IDENTIFIED BY 'lpss';
source /home/vpn.sql
INSERT INTO test(username,password,name,note,mo,quota,now,zq,zxzt,start,active,updata,downdata) VALUES('test', ENCRYPT('123456'),'test','12321',1,10240000,0,30,0,0,1,0,0);
"
fi
rm -f /home/vpn.sql
cp /etc/openvpn/easy-rsa/keys/ca.crt /home/
/etc/init.d/saslauthd restart
/etc/init.d/openvpn restart
service mysqld restart
echo "数据库结构与认证模块测试.."
testsaslauthd -u test -p 123456 -s openvpn
echo '=========================================================================='
echo 远程数据库版安装完毕
echo
echo 数据库地址:$dz 数据库端口:$dk
Client='
配置模板地址:https://github.com/mu228/LPSS/raw/master/cg/openvpn.ovpn
注:证书在home目录
==========================================================================';
echo "$Client";