diff --git a/apt_ostree/cmd/deploy.py b/apt_ostree/cmd/deploy.py index 2ff9d83..b42cac9 100644 --- a/apt_ostree/cmd/deploy.py +++ b/apt_ostree/cmd/deploy.py @@ -18,21 +18,15 @@ from apt_ostree.deploy import Deploy @click.command(help="Deploy a specific commit.") @pass_state_context @branch_argument -@click.option( - "--update", - help="Update grub configuration.", - is_flag=True, - default=False -) @click.option( "-r", "--reboot", help="Initiate a reboot after operation is complete.", is_flag=True, default=False ) -def deploy(state, branch, update, reboot): +def deploy(state, branch, reboot): try: - Deploy(state).deploy(update, reboot) + Deploy(state).deploy(reboot) except KeyboardInterrupt: click.secho("\n" + ("Exiting at your request.")) sys.exit(130) diff --git a/apt_ostree/cmd/options.py b/apt_ostree/cmd/options.py index 67c2bfa..3ee9675 100644 --- a/apt_ostree/cmd/options.py +++ b/apt_ostree/cmd/options.py @@ -253,3 +253,21 @@ def url_option(f): required=True, callback=callback )(f) + + +"""deploy""" + + +def reboot_option(f): + """Reboot host.""" + def callback(ctxt, param, value): + state = ctxt.ensure_object(State) + state.reboot = value + return value + return click.option( + "--reboot", "-r", + help="Reboot host", + is_flag=True, + default=False, + callback=callback + )(f) diff --git a/apt_ostree/deploy.py b/apt_ostree/deploy.py index a42c80c..e8b31ec 100644 --- a/apt_ostree/deploy.py +++ b/apt_ostree/deploy.py @@ -102,7 +102,7 @@ class Deploy: self.ostree.ostree_checkout(branch, self.rootfs) return self.rootfs - def deploy(self, update, reboot): + def deploy(self, reboot): """Run ostree admin deploy.""" ref = self.ostree.ostree_ref(self.state.branch) if not ref: @@ -117,7 +117,7 @@ class Deploy: self.logging.error("Failed to deploy.") sys.exit(1) - if update: + if reboot: self.logging.info("Updating grub.") r = utils.run_command( ["update-grub"] @@ -126,7 +126,6 @@ class Deploy: self.logging.error("Failed to update grub.") sys.exit(1) - if reboot: self.logging.info("Rebooting now.") r = utils.run_command( ["shutdown", "-r", "now"]