Merge pull request #668 from mwhudson/autoinstall-once
only run autoinstall once
This commit is contained in:
commit
323780e642
|
@ -29,6 +29,9 @@ class WelcomeController(SubiquityController):
|
||||||
autoinstall_schema = {'type': 'string'}
|
autoinstall_schema = {'type': 'string'}
|
||||||
autoinstall_default = 'en_US.UTF-8'
|
autoinstall_default = 'en_US.UTF-8'
|
||||||
|
|
||||||
|
def interactive(self):
|
||||||
|
return self.app.interactive()
|
||||||
|
|
||||||
def load_autoinstall_data(self, data):
|
def load_autoinstall_data(self, data):
|
||||||
os.environ["LANG"] = data
|
os.environ["LANG"] = data
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ import shlex
|
||||||
import signal
|
import signal
|
||||||
import sys
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
|
import time
|
||||||
import urwid
|
import urwid
|
||||||
|
|
||||||
import apport.hookutils
|
import apport.hookutils
|
||||||
|
@ -169,9 +170,23 @@ class Subiquity(Application):
|
||||||
s.get_cols_rows = lambda: (80, 24)
|
s.get_cols_rows = lambda: (80, 24)
|
||||||
return s
|
return s
|
||||||
|
|
||||||
|
def get_primary_tty(self):
|
||||||
|
tty = 'tty1'
|
||||||
|
for work in self.kernel_cmdline:
|
||||||
|
if work.startswith('console='):
|
||||||
|
tty = work[len('console='):]
|
||||||
|
return tty
|
||||||
|
|
||||||
def load_autoinstall_config(self):
|
def load_autoinstall_config(self):
|
||||||
with open(self.opts.autoinstall) as fp:
|
with open(self.opts.autoinstall) as fp:
|
||||||
self.autoinstall_config = yaml.safe_load(fp)
|
self.autoinstall_config = yaml.safe_load(fp)
|
||||||
|
primary_tty = self.get_primary_tty()
|
||||||
|
our_tty = os.ttyname(0)
|
||||||
|
if not self.interactive() and our_tty != primary_tty:
|
||||||
|
print(
|
||||||
|
_("the installer running on {} will perform the "
|
||||||
|
"autoinstall").format(primary_tty))
|
||||||
|
signal.pause()
|
||||||
self.controllers.load("Reporting")
|
self.controllers.load("Reporting")
|
||||||
self.controllers.Reporting.start()
|
self.controllers.Reporting.start()
|
||||||
self.controllers.load("Error")
|
self.controllers.load("Error")
|
||||||
|
@ -179,9 +194,18 @@ class Subiquity(Application):
|
||||||
jsonschema.validate(self.autoinstall_config, self.base_schema)
|
jsonschema.validate(self.autoinstall_config, self.base_schema)
|
||||||
self.controllers.load("Early")
|
self.controllers.load("Early")
|
||||||
if self.controllers.Early.cmds:
|
if self.controllers.Early.cmds:
|
||||||
|
stamp_file = os.path.join(self.state_dir, "early-commands")
|
||||||
|
if our_tty != primary_tty:
|
||||||
|
print(
|
||||||
|
_("waiting for installer running on {} to run early "
|
||||||
|
"commands").format(primary_tty))
|
||||||
|
while not os.path.exists(stamp_file):
|
||||||
|
time.sleep(1)
|
||||||
|
else:
|
||||||
self.aio_loop.run_until_complete(
|
self.aio_loop.run_until_complete(
|
||||||
self.controllers.Early.run())
|
self.controllers.Early.run())
|
||||||
self.new_event_loop()
|
self.new_event_loop()
|
||||||
|
open(stamp_file, 'w').close()
|
||||||
with open(self.opts.autoinstall) as fp:
|
with open(self.opts.autoinstall) as fp:
|
||||||
self.autoinstall_config = yaml.safe_load(fp)
|
self.autoinstall_config = yaml.safe_load(fp)
|
||||||
with self.context.child("core_validation", level="INFO"):
|
with self.context.child("core_validation", level="INFO"):
|
||||||
|
|
Loading…
Reference in New Issue