From 5652ba20aebf11fa482c74cd85468bd092bc8213 Mon Sep 17 00:00:00 2001 From: Dylan Taylor Date: Thu, 20 May 2021 16:51:05 -0400 Subject: Extract custom-commands function into general.py --- archinstall/lib/general.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'archinstall/lib/general.py') diff --git a/archinstall/lib/general.py b/archinstall/lib/general.py index 81793cb8..19b7b31c 100644 --- a/archinstall/lib/general.py +++ b/archinstall/lib/general.py @@ -366,3 +366,13 @@ def pid_exists(pid: int): return any(subprocess.check_output(['/usr/bin/ps', '--no-headers', '-o', 'pid', '-p', str(pid)]).strip()) except subprocess.CalledProcessError: return False + + +def run_custom_user_commands(commands): + for index, command in enumerate(commands): + log(f'Executing custom command "{command}" ...', fg='yellow') + with open(f"/mnt/var/tmp/user-command.{index}.sh", "w") as temp_script: + temp_script.write(command) + execution_output = SysCommand(f"arch-chroot /mnt bash /var/tmp/user-command.{index}.sh") + log(execution_output) + os.unlink(f"/mnt/var/tmp/user-command.{index}.sh") -- cgit v1.2.3-70-g09d2 From e6befe53c75b65c88d8f018efc2e6c9479232e9f Mon Sep 17 00:00:00 2001 From: Dylan Taylor Date: Thu, 20 May 2021 17:55:40 -0400 Subject: Use {installation.target} in custom commands handler --- archinstall/lib/general.py | 8 ++++---- examples/guided.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'archinstall/lib/general.py') diff --git a/archinstall/lib/general.py b/archinstall/lib/general.py index 19b7b31c..249c7890 100644 --- a/archinstall/lib/general.py +++ b/archinstall/lib/general.py @@ -368,11 +368,11 @@ def pid_exists(pid: int): return False -def run_custom_user_commands(commands): +def run_custom_user_commands(commands, installation): for index, command in enumerate(commands): log(f'Executing custom command "{command}" ...', fg='yellow') - with open(f"/mnt/var/tmp/user-command.{index}.sh", "w") as temp_script: + with open(f"{installation.target}/var/tmp/user-command.{index}.sh", "w") as temp_script: temp_script.write(command) - execution_output = SysCommand(f"arch-chroot /mnt bash /var/tmp/user-command.{index}.sh") + execution_output = SysCommand(f"arch-chroot {installation.target} bash /var/tmp/user-command.{index}.sh") log(execution_output) - os.unlink(f"/mnt/var/tmp/user-command.{index}.sh") + os.unlink(f"{installation.target}/var/tmp/user-command.{index}.sh") diff --git a/examples/guided.py b/examples/guided.py index fc24ad7e..7de95c72 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -378,7 +378,7 @@ def perform_installation(mountpoint): # If the user provided custom commands to be run post-installation, execute them now. if archinstall.arguments.get('custom-commands', None): - run_custom_user_commands(archinstall.arguments['custom-commands']) + run_custom_user_commands(archinstall.arguments['custom-commands'], installation) installation.log("For post-installation tips, see https://wiki.archlinux.org/index.php/Installation_guide#Post-installation", fg="yellow") if not archinstall.arguments.get('silent'): -- cgit v1.2.3-70-g09d2