write proxy config to installer and target /etc/environment
also emit a signal when proxy config is set
This commit is contained in:
parent
13d7f13c42
commit
605dbdb7d1
|
@ -16,6 +16,7 @@
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from subiquitycore.controller import BaseController
|
from subiquitycore.controller import BaseController
|
||||||
|
from subiquitycore import utils
|
||||||
|
|
||||||
from subiquity.ui.views.proxy import ProxyView
|
from subiquity.ui.views.proxy import ProxyView
|
||||||
|
|
||||||
|
@ -42,4 +43,11 @@ class ProxyController(BaseController):
|
||||||
|
|
||||||
def done(self, proxy):
|
def done(self, proxy):
|
||||||
self.model.proxy = proxy
|
self.model.proxy = proxy
|
||||||
|
if proxy:
|
||||||
|
new_env_path = '/etc/environment'
|
||||||
|
if self.opts.dry_run:
|
||||||
|
new_env_path = '.subiquity' + new_env_path
|
||||||
|
with open(new_env_path, 'w') as fp:
|
||||||
|
fp.write(self.model.etc_environment_content())
|
||||||
|
self.signal.emit_signal('network-proxy-set')
|
||||||
self.signal.emit_signal('next-screen')
|
self.signal.emit_signal('next-screen')
|
||||||
|
|
|
@ -22,3 +22,16 @@ class ProxyModel(object):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.proxy = ""
|
self.proxy = ""
|
||||||
|
|
||||||
|
def etc_environment_content(self):
|
||||||
|
env_lines = []
|
||||||
|
with open("/etc/environment") as fp:
|
||||||
|
for line in fp:
|
||||||
|
if line.startswith('http_proxy=') or line.startswith('https_proxy='):
|
||||||
|
continue
|
||||||
|
if not line.endswith('\n'):
|
||||||
|
line += '\n'
|
||||||
|
env_lines.append(line)
|
||||||
|
env_lines.append("http_proxy={}\n".format(self.proxy))
|
||||||
|
env_lines.append("https_proxy={}\n".format(self.proxy))
|
||||||
|
return ''.join(env_lines)
|
||||||
|
|
|
@ -142,6 +142,10 @@ class SubiquityModel:
|
||||||
'path': 'etc/default/keyboard',
|
'path': 'etc/default/keyboard',
|
||||||
'content': self.keyboard.setting.render(),
|
'content': self.keyboard.setting.render(),
|
||||||
},
|
},
|
||||||
|
'etc_environment': {
|
||||||
|
'path': 'etc/environment',
|
||||||
|
'content': self.proxy.etc_environment_content(),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue