* Clear storage variable if shutdown was successful * Adding shutdown monitoring and debug output. * It seams systemd-run gets a connection reset from running 'shutdown now', but in a good way - so it doesn't raise any exceptions. Or at least that's what it looks like.
This commit is contained in:
parent
c62cef3cfd
commit
565464c72d
|
|
@ -691,6 +691,7 @@ class Installer:
|
||||||
return InstallationFile(self, filename, owner)
|
return InstallationFile(self, filename, owner)
|
||||||
|
|
||||||
def set_keyboard_language(self, language: str) -> bool:
|
def set_keyboard_language(self, language: str) -> bool:
|
||||||
|
log(f"Setting keyboard language to {language}", level=logging.INFO)
|
||||||
if len(language.strip()):
|
if len(language.strip()):
|
||||||
if not verify_keyboard_layout(language):
|
if not verify_keyboard_layout(language):
|
||||||
self.log(f"Invalid keyboard language specified: {language}", fg="red", level=logging.ERROR)
|
self.log(f"Invalid keyboard language specified: {language}", fg="red", level=logging.ERROR)
|
||||||
|
|
@ -712,6 +713,7 @@ class Installer:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def set_x11_keyboard_language(self, language: str) -> bool:
|
def set_x11_keyboard_language(self, language: str) -> bool:
|
||||||
|
log(f"Setting x11 keyboard language to {language}", level=logging.INFO)
|
||||||
"""
|
"""
|
||||||
A fallback function to set x11 layout specifically and separately from console layout.
|
A fallback function to set x11 layout specifically and separately from console layout.
|
||||||
This isn't strictly necessary since .set_keyboard_language() does this as well.
|
This isn't strictly necessary since .set_keyboard_language() does this as well.
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
import logging
|
import logging
|
||||||
|
import time
|
||||||
|
from .exceptions import SysCallError
|
||||||
from .general import SysCommand, SysCommandWorker, locate_binary
|
from .general import SysCommand, SysCommandWorker, locate_binary
|
||||||
from .installer import Installer
|
from .installer import Installer
|
||||||
from .output import log
|
from .output import log
|
||||||
|
|
@ -65,8 +67,10 @@ class Boot:
|
||||||
'-D', self.instance.target,
|
'-D', self.instance.target,
|
||||||
'--timezone=off',
|
'--timezone=off',
|
||||||
'-b',
|
'-b',
|
||||||
|
'--no-pager',
|
||||||
'--machine', self.container_name
|
'--machine', self.container_name
|
||||||
])
|
])
|
||||||
|
# '-P' or --console=pipe could help us not having to do a bunch of os.write() calls, but instead use pipes (stdin, stdout and stderr) as usual.
|
||||||
|
|
||||||
if not self.ready:
|
if not self.ready:
|
||||||
while self.session.is_alive():
|
while self.session.is_alive():
|
||||||
|
|
@ -85,7 +89,14 @@ class Boot:
|
||||||
log(args[1], level=logging.ERROR, fg='red')
|
log(args[1], level=logging.ERROR, fg='red')
|
||||||
log(f"The error above occured in a temporary boot-up of the installation {self.instance}", level=logging.ERROR, fg="red")
|
log(f"The error above occured in a temporary boot-up of the installation {self.instance}", level=logging.ERROR, fg="red")
|
||||||
|
|
||||||
SysCommand(f'machinectl shell {self.container_name} /bin/bash -c "shutdown now"')
|
shutdown = SysCommand(f'systemd-run --machine={self.container_name} --pty /bin/bash -c "shutdown now"')
|
||||||
|
while self.session.is_alive():
|
||||||
|
time.sleep(0.25)
|
||||||
|
|
||||||
|
if shutdown.exit_code == 0:
|
||||||
|
storage['active_boot'] = None
|
||||||
|
else:
|
||||||
|
raise SysCallError(f"Could not shut down temporary boot of {self.instance}", level=logging.ERROR, fg="red")
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
if self.session:
|
if self.session:
|
||||||
|
|
@ -112,10 +123,10 @@ class Boot:
|
||||||
|
|
||||||
cmd[0] = locate_binary(cmd[0])
|
cmd[0] = locate_binary(cmd[0])
|
||||||
|
|
||||||
return SysCommand(["machinectl", "shell", self.container_name, *cmd], *args, **kwargs)
|
return SysCommand(["systemd-run", f"--machine={self.container_name}", "--pty", *cmd], *args, **kwargs)
|
||||||
|
|
||||||
def SysCommandWorker(self, cmd: list, *args, **kwargs):
|
def SysCommandWorker(self, cmd: list, *args, **kwargs):
|
||||||
if cmd[0][0] != '/' and cmd[0][:2] != './':
|
if cmd[0][0] != '/' and cmd[0][:2] != './':
|
||||||
cmd[0] = locate_binary(cmd[0])
|
cmd[0] = locate_binary(cmd[0])
|
||||||
|
|
||||||
return SysCommandWorker(["machinectl", "shell", self.container_name, *cmd], *args, **kwargs)
|
return SysCommandWorker(["systemd-run", f"--machine={self.container_name}", "--pty", *cmd], *args, **kwargs)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue