interplane.Get Omega
Read in your language

spark-connector

aien-dev/spark-connector

Brought by drakestapleton

branch main Branches Tags History

spark-connector / runner / joingen.om

63 lines · 3132 bytes Raw Blame History
1note runner/joingen.om -- writes the join script (dist/join.sh) the hub serves at /community/join.
2note argv: hub URL, sha256 of interplane-runner, sha256 of omc. The script only downloads the two
3note files by their hashes, checks the hashes, prints them with where to compare them, and runs
4note `interplane-runner join`, which explains what it will do and asks before anything is registered.
5note On a computer that is not Linux on aarch64 it says so and installs nothing.
6text jgusage "usage: joingen HUB RUNNER_SHA256 OMC_SHA256\n"
7text jg1 "#!/bin/sh\n# Interplane runner: join this computer to Interplane's community machines.\n# Read it first. Generated by spark-connector runner/joingen.om (rad:z2LKDxnAK3EFfqgr7HTZh6djts65P).\n# It downloads two files, checks their SHA-256, and starts `interplane-runner join`, which explains\n# what it will do and asks for a yes before anything is registered.\nset -eu\nhub='"
8text jg2 "'\nd=\"$HOME/.interplane-runner\"\nif [ \"$(uname -s)\" != Linux ] || [ \"$(uname -m)\" != aarch64 ]; then\n echo \"The Interplane runner needs Linux on 64-bit ARM (aarch64), like an NVIDIA DGX Spark. This computer is $(uname -s) $(uname -m). Nothing was installed.\"\n exit 1\nfi\nif [ -e \"$d/key\" ]; then exec \"$d/bin/interplane-runner\" status; fi\nmkdir -p \"$d/bin\"\nchmod 700 \"$d\"\nget() {\n if curl -fsSL -o \"$d/bin/$1.part\" \"$hub/community/dl/$1-$2\" && [ \"$(sha256sum < \"$d/bin/$1.part\" | cut -d' ' -f1)\" = \"$2\" ]; then\n chmod 700 \"$d/bin/$1.part\"; mv \"$d/bin/$1.part\" \"$d/bin/$1\"\n else\n rm -rf \"$d\"; echo \"The download of $1 failed or its SHA-256 was not $2. Nothing was installed.\"; exit 1\n fi\n}\nget interplane-runner "
9text jg3 "\nget omc "
10text jg4 "\necho \"Downloaded and checked:\"\necho \" interplane-runner sha256 "
11text jg5 "\"\necho \" omc sha256 "
12text jg6 "\"\necho \"Compare them with $hub/community/ (Files and fingerprints) and with SHA256SUMS in the\"\necho \"runner's source, rad:z2LKDxnAK3EFfqgr7HTZh6djts65P.\"\nif (exec < /dev/tty) 2> /dev/null; then exec \"$d/bin/interplane-runner\" join \"$hub\" < /dev/tty; fi\nexec \"$d/bin/interplane-runner\" join \"$hub\"\n"
13
14fn jg_ok s view uchar * hex bool to bool
15if or eq len s 0 gt len s 300
16ret false
17end
18for i ulong len s bound 512
19c = get s i
20lo = or and ge c 97 le c 122 and ge c 48 le c 57
21if hex
22if not and lo not and ge c 103 le c 122
23ret false
24end
25else
26if not or lo or or eq c 46 eq c 45 or eq c 58 eq c 47
27ret false
28end
29end
30end
31ret true
32end
33
34fn main to int
35h = new uchar 512 0
36r = new uchar 80 0
37o = new uchar 80 0
38if ne argcnt 4
39w = write 2 jgusage 0 len jgusage
40ret 2
41end
42hn = argread 1 h 0 400
43rn = argread 2 r 0 80
44on = argread 3 o 0 80
45if or or le hn 0 ne rn 64 ne on 64
46ret 2
47end
48if not and jg_ok part h 0 ulong hn false and jg_ok part r 0 64 true jg_ok part o 0 64 true
49ret 2
50end
51w = write 1 jg1 0 len jg1
52w = write 1 h 0 ulong hn
53w = write 1 jg2 0 len jg2
54w = write 1 r 0 64
55w = write 1 jg3 0 len jg3
56w = write 1 o 0 64
57w = write 1 jg4 0 len jg4
58w = write 1 r 0 64
59w = write 1 jg5 0 len jg5
60w = write 1 o 0 64
61w = write 1 jg6 0 len jg6
62ret 0
63end