From 7d0092de8815e09c6f8307a5e0a109aa618a741b Mon Sep 17 00:00:00 2001 From: Leonardo Robol Date: Tue, 12 Oct 2010 11:31:50 +0200 Subject: [PATCH] Aggiunto support per il proxy su poisson. --- 99_poisson_vpn.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/99_poisson_vpn.py b/99_poisson_vpn.py index c736e29..66ae999 100755 --- a/99_poisson_vpn.py +++ b/99_poisson_vpn.py @@ -22,8 +22,11 @@ __author__ = "Leonardo Robol " +# Defaults +apt_proxy_file = "/etc/apt/apt.conf.d/99poisson_proxy" -import dbus, sys + +import dbus, sys, os from dbus.mainloop.glib import DBusGMainLoop DBusGMainLoop(set_as_default=True) @@ -156,6 +159,20 @@ def activate_connection(connection): connection, dbus.ObjectPath("/"), base_connection) + setup_apt_proxy () + else: + reset_apt_proxy () + +def reset_apt_proxy(): + if os.path.exists(apt_proxy_file): + os.path.remove(apt_proxy_file) + +def setup_apt_proxy(): + if not os.path.exists(apt_proxy_file): + with open(apt_proxy_file, "w") as handle: + handle.write("""Acquire::http { Proxy "http://poisson:3142"; };""") + handle.write("\n") + if __name__ == "__main__": @@ -163,6 +180,7 @@ if __name__ == "__main__": # che ti riattivi quella per poisson (anche perché potresti stare # cercando di liberartente). if sys.argv[2] == "vpn-down": + delete_apt_proxy() sys.exit (0) # Se è appena stata attivata una VPN non ha senso cercare di @@ -174,6 +192,7 @@ if __name__ == "__main__": # Se hai appena deconfigurato un'interfaccia probabilmente non # desideri attivare la VPN if sys.argv[2] == "down": + delete_apt_proxy() sys.exit (0) # Otteniamo il bus @@ -189,7 +208,7 @@ if __name__ == "__main__": # Altrimenti la attiviamo, e poi usciamo :) activate_connection (poisson_vpn) - + sys.exit (0) -- 2.1.4