forked from serverok/squid-proxy-installer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
squid-add-user.sh
60 lines (53 loc) · 1.63 KB
/
squid-add-user.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
#!/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
if [ ! -f /usr/bin/htpasswd ]; then
echo "htpasswd not found"
exit 1
fi
read -e -p "Enter Proxy username: " proxy_username
if [ -f /etc/squid/passwd ]; then
/usr/bin/htpasswd /etc/squid/passwd $proxy_username
else
/usr/bin/htpasswd -c /etc/squid/passwd $proxy_username
fi
if [ ! -f /usr/local/bin/sok-find-os ]; then
echo "/usr/local/bin/sok-find-os not found"
exit 1
fi
SOK_OS=$(/usr/local/bin/sok-find-os)
if [ $SOK_OS == "ubuntu2004" ]; then
systemctl reload squid
elif [ $SOK_OS == "ubuntu1804" ]; then
systemctl reload squid
elif [ $SOK_OS == "ubuntu1604" ]; then
service squid restart
elif [ $SOK_OS == "ubuntu1404" ]; then
service squid3 restart
elif [ $SOK_OS == "debian8" ]; then
service squid3 restart
elif [ $SOK_OS == "debian9" ]; then
systemctl reload squid
elif [ $SOK_OS == "debian10" ]; then
systemctl reload squid
elif [ $SOK_OS == "centos7" ]; then
systemctl reload squid
elif [ $SOK_OS == "centos8" ]; then
systemctl reload squid
else
echo "OS NOT SUPPORTED.\n"
echo "Contact [email protected] to add support for your os."
exit 1;
fi