forked from serverok/squid-proxy-installer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
squid3-install.sh
147 lines (140 loc) · 6.54 KB
/
squid3-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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#!/bin/bash
############################################################
# Squid Proxy Installer
# Author: Yujin Boby
# Email: [email protected]
# Github: https://github.com/serverok/squid-proxy-installer/
# Web: https://serverok.in/squid
############################################################
# For paid support, contact
# https://serverok.in/contact
############################################################
if [ `whoami` != root ]; then
echo "ERROR: You need to run the script as user root or add sudo before command."
exit 1
fi
/usr/bin/wget --no-check-certificate -O /usr/local/bin/sok-find-os https://raw.githubusercontent.com/serverok/squid-proxy-installer/master/sok-find-os.sh > /dev/null 2>&1
chmod 755 /usr/local/bin/sok-find-os
/usr/bin/wget --no-check-certificate -O /usr/local/bin/squid-uninstall https://raw.githubusercontent.com/serverok/squid-proxy-installer/master/squid-uninstall.sh > /dev/null 2>&1
chmod 755 /usr/local/bin/squid-uninstall
/usr/bin/wget --no-check-certificate -O /usr/local/bin/squid-add-user https://raw.githubusercontent.com/serverok/squid-proxy-installer/master/squid-add-user.sh > /dev/null 2>&1
chmod 755 /usr/local/bin/squid-add-user
if [[ -d /etc/squid/ || -d /etc/squid3/ ]]; then
echo "Squid Proxy already installed. If you want to reinstall, first uninstall squid proxy by running command: squid-uninstall"
exit 1
fi
if cat /etc/os-release | grep PRETTY_NAME | grep "Ubuntu 20.04"; then
/usr/bin/apt update
/usr/bin/apt -y install apache2-utils squid3
touch /etc/squid/passwd
/bin/rm -f /etc/squid/squid.conf
/usr/bin/touch /etc/squid/blacklist.acl
/usr/bin/wget --no-check-certificate -O /etc/squid/squid.conf https://raw.githubusercontent.com/xnardo/squid-proxy-installer/master/squid.conf
if [ -f /sbin/iptables ]; then
/sbin/iptables -I INPUT -p tcp --dport 3000 -j ACCEPT
/sbin/iptables-save
fi
service squid restart
systemctl enable squid
elif cat /etc/os-release | grep PRETTY_NAME | grep "Ubuntu 18.04"; then
/usr/bin/apt update
/usr/bin/apt -y install apache2-utils squid3
touch /etc/squid/passwd
/bin/rm -f /etc/squid/squid.conf
/usr/bin/touch /etc/squid/blacklist.acl
/usr/bin/wget --no-check-certificate -O /etc/squid/squid.conf https://raw.githubusercontent.com/xnardo/squid-proxy-installer/master/squid.conf
/sbin/iptables -I INPUT -p tcp --dport 3000 -j ACCEPT
/sbin/iptables-save
service squid restart
systemctl enable squid
elif cat /etc/os-release | grep PRETTY_NAME | grep "Ubuntu 16.04"; then
/usr/bin/apt update
/usr/bin/apt -y install apache2-utils squid3
touch /etc/squid/passwd
/bin/rm -f /etc/squid/squid.conf
/usr/bin/touch /etc/squid/blacklist.acl
/usr/bin/wget --no-check-certificate -O /etc/squid/squid.conf https://raw.githubusercontent.com/xnardo/squid-proxy-installer/master/squid.conf
/sbin/iptables -I INPUT -p tcp --dport 3000 -j ACCEPT
/sbin/iptables-save
service squid restart
update-rc.d squid defaults
elif cat /etc/*release | grep DISTRIB_DESCRIPTION | grep "Ubuntu 14.04"; then
/usr/bin/apt update
/usr/bin/apt -y install apache2-utils squid3
touch /etc/squid3/passwd
/bin/rm -f /etc/squid3/squid.conf
/usr/bin/touch /etc/squid3/blacklist.acl
/usr/bin/wget --no-check-certificate -O /etc/squid3/squid.conf https://raw.githubusercontent.com/xnardo/squid-proxy-installer/master/squid.conf
/sbin/iptables -I INPUT -p tcp --dport 3000 -j ACCEPT
/sbin/iptables-save
service squid3 restart
ln -s /etc/squid3 /etc/squid
#update-rc.d squid3 defaults
ln -s /etc/squid3 /etc/squid
elif cat /etc/os-release | grep PRETTY_NAME | grep "jessie"; then
# OS = Debian 8
/bin/rm -rf /etc/squid
/usr/bin/apt update
/usr/bin/apt -y install apache2-utils squid3
touch /etc/squid3/passwd
/bin/rm -f /etc/squid3/squid.conf
/usr/bin/touch /etc/squid3/blacklist.acl
/usr/bin/wget --no-check-certificate -O /etc/squid3/squid.conf https://raw.githubusercontent.com/xnardo/squid-proxy-installer/master/squid.conf
/sbin/iptables -I INPUT -p tcp --dport 3000 -j ACCEPT
/sbin/iptables-save
service squid3 restart
update-rc.d squid3 defaults
ln -s /etc/squid3 /etc/squid
elif cat /etc/os-release | grep PRETTY_NAME | grep "stretch"; then
# OS = Debian 9
/bin/rm -rf /etc/squid
/usr/bin/apt update
/usr/bin/apt -y install apache2-utils squid
touch /etc/squid/passwd
/bin/rm -f /etc/squid/squid.conf
/usr/bin/touch /etc/squid/blacklist.acl
/usr/bin/wget --no-check-certificate -O /etc/squid/squid.conf https://raw.githubusercontent.com/xnardo/squid-proxy-installer/master/squid.conf
/sbin/iptables -I INPUT -p tcp --dport 3128 -j ACCEPT
/sbin/iptables-save
systemctl enable squid
systemctl restart squid
elif cat /etc/os-release | grep PRETTY_NAME | grep "buster"; then
# OS = Debian 10
/bin/rm -rf /etc/squid
/usr/bin/apt update
/usr/bin/apt -y install apache2-utils squid
touch /etc/squid/passwd
/bin/rm -f /etc/squid/squid.conf
/usr/bin/touch /etc/squid/blacklist.acl
/usr/bin/wget --no-check-certificate -O /etc/squid/squid.conf https://raw.githubusercontent.com/xnardo/squid-proxy-installer/master/squid.conf
/sbin/iptables -I INPUT -p tcp --dport 3128 -j ACCEPT
/sbin/iptables-save
systemctl enable squid
systemctl restart squid
elif cat /etc/os-release | grep PRETTY_NAME | grep "CentOS Linux 7"; then
yum install squid httpd-tools -y
/bin/rm -f /etc/squid/squid.conf
/usr/bin/touch /etc/squid/blacklist.acl
/usr/bin/wget --no-check-certificate -O /etc/squid/squid.conf https://raw.githubusercontent.com/serverok/squid-proxy-installer/master/conf/squid-centos7.conf
systemctl enable squid
systemctl restart squid
firewall-cmd --zone=public --permanent --add-port=3128/tcp
firewall-cmd --reload
elif cat /etc/os-release | grep PRETTY_NAME | grep "CentOS Linux 8"; then
yum install squid httpd-tools -y
/bin/rm -f /etc/squid/squid.conf
/usr/bin/touch /etc/squid/blacklist.acl
/usr/bin/wget --no-check-certificate -O /etc/squid/squid.conf https://raw.githubusercontent.com/serverok/squid-proxy-installer/master/conf/squid-centos7.conf
systemctl enable squid
systemctl restart squid
firewall-cmd --zone=public --permanent --add-port=3128/tcp
firewall-cmd --reload
else
echo "OS NOT SUPPORTED.\n"
echo "Contact https://serverok.in/contact to add support for your os."
exit 1;
fi
echo
echo "Thank you for using ServerOk.in Squid Proxy Installer."
echo "To create a proxy user, run command: squid-add-user"
echo