Skip to content

Commit e73b332

Browse files
committed
Improve shell, fix rollback
1 parent 8452b8e commit e73b332

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

atomic-update.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,10 @@ def sigint_handler(signum, frame):
350350
if SHELL:
351351
logging.info(f"Opening bash shell within chroot of snapshot {atomic_snap}")
352352
logging.info("Continue with 'exit' or discard with 'exit 1'")
353-
ret = os.system(f"chroot {TMP_MOUNT_DIR} env PS1='atomic-update:${{PWD}} # ' bash --noprofile --norc")
353+
command = f"""
354+
chroot {TMP_MOUNT_DIR} bash -c "export PS1='atomic-update:\${{PWD}} # '; exec bash"
355+
"""
356+
ret = os.system(command)
354357
if ret != 0:
355358
logging.error(f"Shell returned exit code {ret}. Discarding snapshot {atomic_snap}")
356359
shell_exec(f"snapper -c {snapper_root_config} delete {atomic_snap}")
@@ -403,15 +406,15 @@ def sigint_handler(signum, frame):
403406
# Handle command: rollback
404407
elif COMMAND == "rollback":
405408
invalid_opts = OPT.copy()
406-
invalid_opts.remove("--debug")
409+
invalid_opts.remove("--debug") if "--debug" in OPT else None
407410
if invalid_opts:
408411
logging.warn(f"Options {', '.join(invalid_opts)!r} do not apply to rollback command")
409412
if rollback_num:
410413
logging.info(f"Rolling back to snapshot {rollback_num}")
411-
os.system(f"snapper rollback {rollback_num}")
414+
os.system(f"snapper rollback -c number {rollback_num}")
412415
else:
413416
logging.info("Rolling back to currently booted snapshot")
414-
os.system("snapper rollback")
417+
os.system("snapper rollback -c number")
415418

416419
# If we're here, remind user to reboot
417420
logging.info("Please reboot your machine to activate the changes and avoid data loss")

0 commit comments

Comments
 (0)