-
Notifications
You must be signed in to change notification settings - Fork 6
/
init
executable file
·30 lines (26 loc) · 975 Bytes
/
init
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
#!/bin/sh
if [ -n "${CACHE_PEER}" ]; then
url=$CACHE_PEER
# extract the user and password (if any)
userpass="`echo $url | grep @ | cut -d@ -f1`"
pass=`echo $userpass | grep : | cut -d: -f2`
if [ -n "$pass" ]; then
user=`echo $userpass | grep : | cut -d: -f1`
else
user=$userpass
fi
# extract the host -- updated
hostport=`echo $url | sed -e s,$userpass@,,g | cut -d/ -f1`
port=`echo $hostport | grep : | cut -d: -f2`
if [ -n "$port" ]; then
host=`echo $hostport | grep : | cut -d: -f1`
else
host=$hostport
fi
echo "cache_peer $host parent $port 0 no-query default login=$userpass" >> /etc/squid3/squid.conf
echo "never_direct allow all" >> /etc/squid3/squid.conf
fi
# -X verbose debug logging
#squid -N -X
htpasswd -bc /usr/etc/passwd "${SQUID_USERNAME}" "${SQUID_PASSWORD}"
exec squid3 -N $*