summaryrefslogtreecommitdiff
path: root/chip
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2019-03-02 17:48:32 -0800
committerBen Sima <ben@bsima.me>2019-03-02 17:50:39 -0800
commitf9524766bd7eba9c429492017485d61188b76c87 (patch)
treeef67af35c3f8947a15947e4b4a7a22ffaba4c59c /chip
parent3d0df3ed30014f22574af4b390553930ef7cbb7f (diff)
Better deploy script
Diffstat (limited to 'chip')
-rwxr-xr-xchip/push41
1 files changed, 41 insertions, 0 deletions
diff --git a/chip/push b/chip/push
new file mode 100755
index 0000000..48a7cc4
--- /dev/null
+++ b/chip/push
@@ -0,0 +1,41 @@
+#!/usr/bin/env python3
+
+import argparse
+import os
+import subprocess
+import tempfile
+import importlib.util
+
+cli = argparse.ArgumentParser(description='deploy a thing')
+cli.add_argument('depo', type=str,
+ help='the depo roun to deploy')
+
+args = cli.parse_args()
+
+cwd = os.getcwd()
+bild_dir = f"{cwd}/bild"
+
+src = f"{cwd}/depo/{args.depo}"
+out = f"{bild_dir}/{args.depo}"
+
+
+# bild
+subprocess.run(["nix-build", "-A", f"depo.{args.depo}",
+ "--out-link", out])
+print("bilt")
+
+
+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}"])
+print("sent")
+
+# switch
+subprocess.run(["ssh", f"root@{ip}", "sudo",
+ f"{os.readlink(out)}/bin/switch-to-configuration",
+ "switch"])
+
+print(f"pushed {args.depo} -> {ip}")