support pre-run, post-run commands

main
Mirko Brombin 2 years ago
parent 1a9b4db2b1
commit c689be9aa2

@ -2,6 +2,14 @@
"log_file": "/etc/vanilla/first-setup.log",
"distro_name": "Vanilla OS",
"distro_logo": "io.github.vanilla-os.FirstSetup",
"pre_run": [
"sudo apt update",
"sudo apt install -f"
],
"post_run": [
"sudo apt update",
"sudo apt install -f"
],
"steps": {
"welcome": {
"template": "welcome"
@ -115,7 +123,7 @@
"if": "immutability",
"type": "command",
"commands": [
"sudo apt install -y almost",
"sudo apt install -y almost almost-extras",
"sudo almost enter rw"
]
}

@ -26,7 +26,9 @@ logger = logging.getLogger("FirstSetup::Processor")
class Processor:
@staticmethod
def run(log_path, commands):
def run(log_path, pre_run, post_run, commands):
command = pre_run + commands + post_run
logger.info("processing the following commands: \n%s" %
'\n'.join(commands))
@ -65,7 +67,8 @@ class Processor:
log.flush()
except Exception as e:
logger.warning("failed to write to the log file: %s" % e)
logger.warning("the output of the commands is: %s" % proc.stdout)
logger.warning("the output of the commands is: %s" %
proc.stdout.decode('utf-8'))
if proc.returncode != 0:
logger.critical(

@ -69,7 +69,12 @@ class VanillaWindow(Adw.ApplicationWindow):
commands = Parser.parse(finals)
# process the commands
return Processor.run(self.recipe["log_file"], commands)
return Processor.run(
self.recipe.get("log_file", "/tmp/vanilla_first_setup.log"),
self.recipe.get("pre_run", []),
self.recipe.get("post_run"),
commands
)
def on_done(result, *args):
self.__view_done.set_result(result)

Loading…
Cancel
Save