Bug#681421: apt: Acquire::http { proxy } should be made location-aware
On 13 July 2012 07:22, Felicitus <felicitus@felicitus.org> wrote:
> I'm using a proxy configuration for my notebook:
>
> Acquire::http { Proxy "http://<ip>:3142"; };
>
> However, when I switch locations (like from home to hackerspace or to work), I
> need to uncomment/change that line depending on whatever location I'm at.
>
> It would be nice if this could be automated
Hello
You can place network-specific configurations in /etc/apt/apt.conf.d
and use scripts to enable them as appropriate. For example, I have
similar proxy settings in 99eth0-home and use this script
--- /usr/local/sbin/toggle-apt-conf
#!/bin/sh
set -e
base="/etc/apt/apt.conf.d/$2"
case $1 in
enable) [ -f "$base.disabled" ] && mv "$base.disabled" "$base" ;;
disable) [ -f "$base" ] && mv "$base" "$base.disabled" ;;
esac
---
with these network settings
--- /etc/network/interfaces
…
iface eth0-home inet static
address 192.168.1.3
netmask 255.255.255.0
up toggle-apt-conf enable 99eth0-home
down toggle-apt-conf disable 99eth0-home
---
to enable the proxy automatically when I connect to my home network.
This is also possible to do using network manager, though the
configuration is obviously different.
Regards
Reply to: