- initial import of revision 374 from cnc
[apt.git] / contrib / proxypasswd / proxypasswd.lua
1 # use with Scripts::Init::=proxypasswd.lua
2 http_proxy = confget("Acquire::http::proxy")
3 ftp_proxy = confget("Acquire::ftp::proxy")
4 if http_proxy == "" and ftp_proxy == "" then
5         return
6 end
7
8 print(_("Enter proxy username:"))
9 username = io.read()
10 print(_("Enter proxy password:"))
11 os.execute("stty -echo")
12 password = io.read()
13 os.execute("stty echo")
14
15 if http_proxy then
16         http_proxy = string.gsub(http_proxy, "/username:", "/"..username..":")
17         http_proxy = string.gsub(http_proxy, ":password@", ":"..password.."@")
18         confset("Acquire::http::proxy", http_proxy)
19 end
20 if ftp_proxy then
21         ftp_proxy = string.gsub(ftp_proxy, "/username:", "/"..username..":")
22         ftp_proxy = string.gsub(ftp_proxy, ":password@", ":"..password.."@")
23         confset("Acquire::ftp::proxy", ftp_proxy) 
24 end
25