forked from squidproxy/squidproxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathautodevelopmentPAC.sh
88 lines (61 loc) · 1.81 KB
/
autodevelopmentPAC.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
#!/bin/bash
#
# Author: Dave feng
# twitter: https://twitter.com/squidgfw
#
# Installs a PAC Server
# Check if user is root
[ $(id -u) != "0" ] && { echo -e "\033[31mError: You must be root to run this script\033[0m"; exit 1; }
sudo aptitude install -y apache2 apache2-doc
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
clear
while :; do echo
read -p "Please input PAC file'S name: " PACname
[ -n "PACname" ] && break
done
if [ ! -d "/var/www/html" ]
then
echo "Next step"
else
wget --no-check-certificate -O /var/www/html/$PACname https://raw.githubusercontent.com/squidproxy/squidproxy/master/PAC/Squidproxy.pac
fi
if [ ! -d "/var/www" ]
then
echo "Next step"
else
wget --no-check-certificate -O /var/www/$PACname https://raw.githubusercontent.com/squidproxy/squidproxy/master/PAC/Squidproxy.pac
fi
apt-get -y install wget || {
echo "Could not install wget, required to retrieve your IP address."
exit 1
}
#find out external ip
Serverip=`wget -q -O - http://api.ipify.org`
if [ "x$Serverip" = "x" ]
then
echo "============================================================"
echo " !!! COULD NOT DETECT SERVER EXTERNAL IP ADDRESS !!!"
else
echo "============================================================"
echo "Detected your server external ip address: $Serverip"
fi
#while :; do echo
# read -p "Please input Server ip: " Serverip
# [ -n "Serverip" ] && break
# done
if [ ! -d "/var/www" ]
then
echo "Next step"
else
perl -p -i -e "s/VPS-IP/$Serverip/g" /var/www/*.pac
fi
if [ ! -d "/var/www/html" ]
then
echo "Next step"
else
perl -p -i -e "s/VPS-IP/$Serverip/g" /var/www/html*.pac
fi
echo ""
echo "Your PAC is http://$Serverip/$PACname"
echo "============================================================"
sleep 2