Skip to content

Commit

Permalink
Adding a cmd_history.txt log under /var/log/archinstall/ (#737)
Browse files Browse the repository at this point in the history
* Adding a cmd_history.txt log under /var/log/archinstall/ to get a clear picture of which commands was executed.
  • Loading branch information
Torxed authored Nov 18, 2021
1 parent 4e3d2cf commit 5ec690d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
11 changes: 9 additions & 2 deletions archinstall/lib/disk/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,16 @@ def get_filesystem_type(path):

def disk_layouts():
try:
return json.loads(SysCommand("lsblk -f -o+TYPE,SIZE -J").decode('UTF-8'))
if (handle := SysCommand("lsblk -f -o+TYPE,SIZE -J")).exit_code == 0:
return json.loads(handle.decode('UTF-8'))
else:
log(f"Could not return disk layouts: {handle}", level=logging.WARNING, fg="yellow")
return None
except SysCallError as err:
log(f"Could not return disk layouts: {err}")
log(f"Could not return disk layouts: {err}", level=logging.WARNING, fg="yellow")
return None
except json.decoder.JSONDecodeError as err:
log(f"Could not return disk layouts: {err}", level=logging.WARNING, fg="yellow")
return None


Expand Down
7 changes: 7 additions & 0 deletions archinstall/lib/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,16 @@ def execute(self) -> bool:

if not self.pid:
try:
try:
with open(f"{storage['LOG_PATH']}/cmd_history.txt", "a") as cmd_log:
cmd_log.write(f"{' '.join(self.cmd)}\n")
except PermissionError:
pass

os.execve(self.cmd[0], self.cmd, {**os.environ, **self.environment_vars})
if storage['arguments'].get('debug'):
log(f"Executing: {self.cmd}", level=logging.DEBUG)

except FileNotFoundError:
log(f"{self.cmd[0]} does not exist.", level=logging.ERROR, fg="red")
self.exit_code = 1
Expand Down

0 comments on commit 5ec690d

Please sign in to comment.