forked from centminmod/squid-proxy-installer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspi
executable file
·189 lines (186 loc) · 6.48 KB
/
spi
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
#!/bin/bash
########################################################################
# Squid Proxy Installer 1.1 #
# Homepage: https://hiddenrefuge.eu.org/projects/squid-proxy-installer #
# Copyright© 2014 - 2015 by Hidden-Refuge #
# License: GNU GPL 3 #
# https://www.gnu.org/licenses/gpl.html #
# modified for centminmod.com centos 6/7 Centmin Mod LEMP stack + CSF #
########################################################################
arch=$(getconf LONG_BIT)
csfsetup() {
# For centminmod.com LEMP stack's CSF Firewall default install
if [ -f /etc/csf/csf.conf ]; then
sed -i "s/TCP_IN = \"/TCP_IN = \"3128,/g" /etc/csf/csf.conf
sed -i "s/TCP6_IN = \"/TCP6_IN = \"3128,/g" /etc/csf/csf.conf
csf -r
else
iptables -A INPUT -p tcp --dport 3128 -j ACCEPT
service iptables save
fi
}
rhel5 () {
rpm -Uvh http://flexbox.sourceforge.net/centos/5/i386/flexbox-release-1-4.3.noarch.rpm
yum install perl-DBI libecap squid httpd -y
read -e -p "Your desired username: " usrn
htpasswd -c /etc/squid/passwd $usrn
case $arch in
32)
wget -O /etc/squid/squid.conf https://raw.githubusercontent.com/hidden-refuge/squid-proxy-installer/master/spi-rhel5632.conf --no-check-certificate;;
64)
wget -O /etc/squid/squid.conf https://raw.githubusercontent.com/hidden-refuge/squid-proxy-installer/master/spi-rhel5664.conf --no-check-certificate;;
esac
service squid restart && chkconfig squid on
service httpd stop && chkconfig httpd off
csfsetup
echo
echo "squid proxy installed"
}
rhel6 () {
# don't need httpd-tools if using centminmod.com stack as
# it has it's own more secure htpasswd.sh capable of longer
# and more secure password hashing support
if [ -f /usr/local/nginx/conf/htpasswd.sh ]; then
yum install squid -y
else
yum install squid httpd-tools -y
fi
read -e -p "Your desired username: " usrn
if [ -f /usr/local/nginx/conf/htpasswd.sh ]; then
read -e -p "Your desired password: " usrp
/usr/local/nginx/conf/htpasswd.sh create /etc/squid/passwd $usrn $usrp
else
htpasswd -c /etc/squid/passwd $usrn
fi
case $arch in
32)
wget -O /etc/squid/squid.conf https://raw.githubusercontent.com/hidden-refuge/squid-proxy-installer/master/spi-rhel5632.conf --no-check-certificate;;
64)
wget -O /etc/squid/squid.conf https://raw.githubusercontent.com/hidden-refuge/squid-proxy-installer/master/spi-rhel5664.conf --no-check-certificate;;
esac
service squid restart && chkconfig squid on
csfsetup
echo
echo "squid proxy installed"
}
rhel7 () {
# don't need httpd-tools if using centminmod.com stack as
# it has it's own more secure htpasswd.sh capable of longer
# and more secure password hashing support
if [ -f /usr/local/nginx/conf/htpasswd.sh ]; then
yum install squid -y
else
yum install squid httpd-tools -y
fi
read -e -p "Your desired username: " usrn
if [ -f /usr/local/nginx/conf/htpasswd.sh ]; then
read -e -p "Your desired password: " usrp
/usr/local/nginx/conf/htpasswd.sh create /etc/squid/passwd $usrn $usrp
else
htpasswd -c /etc/squid/passwd $usrn
fi
wget -O /etc/squid/squid.conf https://raw.githubusercontent.com/hidden-refuge/squid-proxy-installer/master/spi-rhel7.conf --no-check-certificate
systemctl restart squid.service && systemctl enable squid.service
csfsetup
echo
echo "squid proxy installed"
}
deb () {
apt-get update
apt-get install apache2-utils squid3 -y
read -e -p "Your desired username: " usrn
htpasswd -c /etc/squid3/passwd $usrn
wget -O /etc/squid3/squid.conf https://raw.githubusercontent.com/hidden-refuge/squid-proxy-installer/master/spi-debian.conf --no-check-certificate
service squid3 restart && update-rc.d squid3 defaults
iptables -A INPUT -p tcp --dport 3128 -j ACCEPT
iptables-save
echo
echo "squid proxy installed"
}
deb8 () {
apt-get update
apt-get install apache2-utils squid3 -y
read -e -p "Your desired username: " usrn
htpasswd -c /etc/squid3/passwd $usrn
wget -O /etc/squid3/squid.conf https://raw.githubusercontent.com/hidden-refuge/squid-proxy-installer/master/spi-jessie.conf --no-check-certificate
service squid3 restart && update-rc.d squid3 defaults
iptables -A INPUT -p tcp --dport 3128 -j ACCEPT
iptables-save
echo
echo "squid proxy installed"
}
ubt () {
apt-get update
apt-get install apache2-utils squid3 -y
read -e -p "Your desired username: " usrn
htpasswd -c /etc/squid3/passwd $usrn
wget -O /etc/squid3/squid.conf https://raw.githubusercontent.com/hidden-refuge/squid-proxy-installer/master/spi-ubuntu.conf --no-check-certificate
cp /etc/init/squid3.conf /etc/init.d/squid3
service squid3 restart && update-rc.d squid3 defaults
iptables -A INPUT -p tcp --dport 3128 -j ACCEPT
iptables-save
echo
echo "squid proxy installed"
}
fed() {
yum install squid httpd-tools -y
read -e -p "Your desired username: " usrn
htpasswd -c /etc/squid/passwd $usrn
case $arch in
32)
wget -O /etc/squid/squid.conf https://raw.githubusercontent.com/hidden-refuge/squid-proxy-installer/master/spi-fedora32.conf --no-check-certificate;;
64)
wget -O /etc/squid/squid.conf https://raw.githubusercontent.com/hidden-refuge/squid-proxy-installer/master/spi-rhel7.conf --no-check-certificate;;
esac
systemctl restart squid && systemctl enable squid
iptables -A INPUT -p tcp --dport 3128 -j ACCEPT
iptables-save
echo
echo "squid proxy installed"
}
info () {
echo "Squid Proxy Installer 1.1"
echo ""
echo "Usage: ./spi <option>"
echo "Example for Debian 6/7: ./spi -debian"
echo ""
echo "Options:"
echo "-rhel5 <<-- RHEL 5 based OS 32/64 Bit"
echo "-rhel6 <<-- RHEL 6 based OS 32/64 Bit"
echo "-rhel7 <<-- RHEL 7 based OS 32/64 Bit"
echo "-debian <<-- Debian 6,7 32/64 Bit"
echo "-jessie <<-- Debian 8 32/64 Bit"
echo "-ubuntu <<-- Ubuntu 32/64 Bit"
echo "-fedora <<-- Fedora 32/64 Bit"
echo ""
echo "RHEL 5: CentOS 5, Scientific Linux 5, etc.."
echo "RHEL 6: CentOS 6, Scientific Linux 6, etc.."
echo "RHEL 7: CentOS 7, Scientific Linux 7, etc.."
echo ""
echo "To add more users use the command below:"
echo "Debian/Ubuntu: htpasswd /etc/squid3/passwd username"
if [ -f /usr/local/nginx/conf/htpasswd.sh ]; then
echo "RHEL/Fedora: /usr/local/nginx/conf/htpasswd.sh create /etc/squid/passwd username password"
else
echo "RHEL/Fedora: htpasswd /etc/squid/passwd username"
fi
echo ""
}
case $1 in
'-rhel5')
rhel5;;
'-rhel6')
rhel6;;
'-rhel7')
rhel7;;
'-debian')
deb;;
'-jessie')
deb8;;
'-ubuntu')
ubt;;
'-fedora')
fed;;
*)
info;;
esac