summaryrefslogtreecommitdiff
path: root/chip
diff options
context:
space:
mode:
Diffstat (limited to 'chip')
-rwxr-xr-xchip/push27
1 files changed, 15 insertions, 12 deletions
diff --git a/chip/push b/chip/push
index 96cc893..1b8c1f8 100755
--- a/chip/push
+++ b/chip/push
@@ -6,6 +6,14 @@ import subprocess
import tempfile
import importlib.util
+def shell(*args):
+ "Run a shell command and capture the output."
+ try:
+ proc = subprocess.run(args, check=True, capture_output=True)
+ except subprocess.CalledProcessError as e:
+ raise RuntimeError(f'{e.cmd} error {e.returncode}: {e.output}')
+ return proc.stdout.strip().decode('utf8')
+
cli = argparse.ArgumentParser(description='deploy a thing')
cli.add_argument('depo', type=str,
help='the depo roun to deploy')
@@ -20,22 +28,17 @@ out = f"{bild_dir}/{args.depo}"
# bild
-subprocess.run(["nix-build", "-A", f"depo.{args.depo}",
- "--out-link", out])
+shell("nix-build", "-A", f"depo.{args.depo}", "--out-link", out)
print("bilt")
-# get roun
-p = subprocess.run(["chip/roun", args.depo, "-i"],
- stdout=subprocess.PIPE)
-ip = p.stdout.decode()
-
# push
-subprocess.run(["nix", "copy", "--to", f"ssh://root@{ip}", f"{out}"])
+shell("nix", "copy", "--to", f"ssh://root@{args.depo}", f"{out}")
print("sent")
# switch
-subprocess.run(["ssh", f"root@{ip}", "sudo",
- f"{os.readlink(out)}/bin/switch-to-configuration",
- "switch"])
+shell("ssh", f"root@{args.depo}", "sudo",
+ f"{os.readlink(out)}/bin/switch-to-configuration",
+ "switch")
+print("switched")
-print(f"pushed {args.depo} -> {ip}")
+print(f"pushed {args.depo}")