Skip to content

Instantly share code, notes, and snippets.

@ma08
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ma08/94020d6f960378122779 to your computer and use it in GitHub Desktop.
Save ma08/94020d6f960378122779 to your computer and use it in GitHub Desktop.
#!/bin/bash
minind=0
min="1212.000"
proxies=(
"http://144.16.192.213:8080"
"http://144.16.192.216:8080"
"http://144.16.192.217:8080"
"http://144.16.192.218:8080"
"http://144.16.192.245:8080"
"http://144.16.192.247:8080"
"http://10.3.100.211:8080"
"http://10.3.100.212:8080")
proxies3=(
"144.16.192.213"
"144.16.192.216"
"144.16.192.217"
"144.16.192.218"
"144.16.192.245"
"144.16.192.247"
"10.3.100.211"
"10.3.100.212")
for (( c=0; c<${#proxies[@]}; c++ ))
do
var=$(curl --no-sessionid -x "${proxies[c]}" -o ./proxyfile.pdf -s -w %{time_total}\\n http://www.cred.be/download/download.php?file=sites/default/files/CredCrunch15.pdf)
echo ${proxies[c]} $var
var2=$(echo "$min > $var" | bc)
if [ "$var" != "0.000" ]&&[ "$var2" == "1" ];
then
min=$var
minind=$c
fi
done
rm proxyfile.pdf
if [ "$min" == "0.000" ];
then
echo "Possible network problems, no connection"
return 0
fi
echo "Best----" ${proxies[minind]}
#----Ubuntu Specific Code-----
source ./bus.sh
HTTP_PROXY_HOST=${proxies3[minind]}
HTTP_PROXY_PORT=8080
HTTPS_PROXY_HOST=${proxies3[minind]}
HTTPS_PROXY_PORT=8080
gsettings set org.gnome.system.proxy.http host "$HTTP_PROXY_HOST"
gsettings set org.gnome.system.proxy.http port "$HTTP_PROXY_PORT"
gsettings set org.gnome.system.proxy.https host "$HTTPS_PROXY_HOST"
gsettings set org.gnome.system.proxy.https port "$HTTPS_PROXY_PORT"
sudo sed -i.bak '/http[s]::proxy/Id' /etc/apt/apt.conf
sudo tee -a /etc/apt/apt.conf <<EOF
Acquire::http::proxy "http://$HTTP_PROXY_HOST:$HTTP_PROXY_PORT/";
Acquire::https::proxy "http://$HTTPS_PROXY_HOST:$HTTPS_PROXY_PORT/";
EOF
sudo sed -i.bak '/http[s]_proxy/Id' /etc/environment
sudo tee -a /etc/environment <<EOF
http_proxy="http://$HTTP_PROXY_HOST:$HTTP_PROXY_PORT/"
https_proxy="http://$HTTPS_PROXY_HOST:$HTTPS_PROXY_PORT/"
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment